Ejemplo n.º 1
0
	/*******************************************************
		Function: do_compile

		Actually perform compilation

	 *******************************************************/
int
do_compile (string *argv)
{
    int pid;
    
    if (toolroot == 0) {
	if ((toolroot = getenv ("TOOLROOT")) == 0)
	    toolroot = "/usr/bin/";
	else
	    toolroot = concat_names (toolroot, "/usr/bin/");
    }

    argv[0] = concat_names (toolroot, basename (argv[0]));

#ifdef  TARG_MIPS
    if (option[OPT_VERBOSE].flag || option[OPT_SHOW].flag)
	dump_argv (argv);
#else
#endif

    pid = pcreateve (argv[0], argv, environ_vars);

    if (pid < 0) {
    	perror(argv[0]);
	exit(1);
    }

    active_pid = pid;
    
    FREE (argv[0]);

    return pid;

} /* do_compile */
Ejemplo n.º 2
0
	/*******************************************************
		Function: do_compile

		Actually perform compilation

	 *******************************************************/
int
do_compile (string *argv)
{
    int pid;
    
    if (toolroot) {
	    toolroot = concat_names (toolroot, DEFAULT_TOOLROOT);
    }

    argv[0] = concat_names (toolroot, basename (argv[0]));

    if (ld_ipa_opt[LD_IPA_VERBOSE].flag || ld_ipa_opt[LD_IPA_SHOW].flag)
	dump_argv (argv);

    pid = fork();
    pid = execve(argv[0], argv, environ_vars);

    if (pid < 0) {
    	perror(argv[0]);
	exit(1);
    }

    active_pid = pid;
    
    FREE (argv[0]);
    argv[0] = NULL;

    if (toolroot) {
    	FREE (toolroot);
	toolroot = NULL;
    }

    return pid;

} /* do_compile */
Ejemplo n.º 3
0
static void
add_WB_opt (char **argv)
{
    char *p = *argv;

    if ( WB_flags == NULL ) {
    	WB_flags = concat_names("-Wb,",&p[3]);
    } else {
    	char *flg = concat_names(WB_flags,&p[3] ); /* include the comma */
    	FREE(WB_flags);
    	WB_flags = flg;
  }

  return;
}
Ejemplo n.º 4
0
	/*******************************************************
		Function: make_link

		

	 *******************************************************/
int
make_link (const string dest, const string src)
{
    static string working_dir = 0;
    int link_result;

#if 0
    LD_ASSERT (dest && src, thisfile,
	       "NULL path name passed to symbolic_link()");
#endif

    /* try hard link first */

    if (link (dest, src) == 0)
	return 0;
    
    /* hard link fails, try symbolic link */

    if (dest[0] == '/')
	link_result = symlink (dest, src);
    else {
	string new_dest;
	
	if (working_dir == 0) {
	    string tmp;
	    working_dir = getcwd ((char *) NULL, PATH_MAX);
	    if (working_dir == NULL) {
		perror("getcwd(3)");
		exit(1);
    	    }
	    tmp = working_dir;
	    working_dir = concat_names (working_dir, "/");
	    FREE (tmp);
	}

	new_dest = concat_names (working_dir, dest);
	link_result = symlink (new_dest, src);
	FREE (new_dest);
    }

    return link_result;
    
} /* make_link */
Ejemplo n.º 5
0
static void
add_Y_opt (char **argv)
{
    char *p = *argv;

    if ( Y_flags == NULL ) {
    	Y_flags = ipa_copy_of(p);
    } else {
    	char *flg;
	
	flg = concat_names(Y_flags," ");
	FREE (Y_flags);
	Y_flags = flg;
	
	flg = concat_names(Y_flags,p);
	FREE (Y_flags);
	Y_flags = flg;
    }

    return;
}
Ejemplo n.º 6
0
int
create_tmpdir ( int tracing )
{
    int fixedname = ipa && ( option[OPT_KEEP_TEMPS].flag );

    if ( ipa ) {
	if ( fixedname ) {
	    tmpdir = concat_names ( outfilename, ".ipakeep" );
	} else {
	    char *tmpdir_env_var;
	    if ((tmpdir_env_var = getenv("TMPDIR")) != NULL) {
		char *filename;
	        tmpdir_env_var = concat_names ( tmpdir_env_var, DIR_SEP_CHAR);
		if ((filename = strrchr(outfilename, DIR_SEP_CHAR)) != NULL)
		    filename++;
		else
		    filename = outfilename;
		
	        tmpdir = concat_names ( tmpdir_env_var, filename);
	    }
	    else
	        tmpdir = outfilename;
	    tmpdir = concat_names ( tmpdir, ".ipaXXXXXX" );
	}
    } else {
	tmpdir = concat_names ( DEFAULT_TMPDIR, "XXXXXX" );
    }
    if ( ! fixedname ) {
	tmpdir = mktemp ( tmpdir );
    }
    tmpdir_length = strlen ( tmpdir );

    if ( cmask == 0 ) {
	cmask = umask (0);
	(void) umask (cmask);
    }

    if ( MKDIR (tmpdir, 0777 & ~cmask) != 0 ) {
	if ( errno == EEXIST && fixedname ) {
	    /* We have an old instance of this directory -- clear it out: */
	    DIR *dirp;
	    struct direct *entryp;
	    char *prefix;

	    dirp = opendir ( tmpdir );
	    if ( dirp != NULL ) {
		prefix = concat_names ( tmpdir, "/" );
		while ( ( entryp = readdir(dirp) ) != NULL ) {
		    /* Don't bother with names of one or two characters, e.g. '.'
		     * and '..', since we don't create temporary files with such
		     * names:
		     */
#if defined(_DIRENT_HAVE_D_NAMLEN)
		  if ( entryp->d_namlen > 2 )
#else
		  if (_D_EXACT_NAMLEN(entryp) > 2)
#endif
		    {
			string fname = concat_names ( prefix, entryp->d_name);
			unlink (fname);
			FREE (fname);
		    }
		}
		FREE (prefix);
		closedir ( dirp );
	    }
	} else {
    	    perror(""cannot create temporary directory for code generation");
	    return -1;
	}
    }

    add_to_tmp_file_list ( tmpdir );

    return 0;

} /* create_tmpdir */