X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: dj AT delorie DOT com X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jWmG+FgWGUAM1v1252Uf5qMw6KKz4HgDtST4pUdleeI=; b=W2KxteRF6N68Dn/qyIvEjBTIwMeDBYuG08e0h74gnDMbQ7GbLI4e9rVw87lu2GaDGW /KZj4xMuMuUE1/1vdMxhcPLB5y88FWZzwHwoREY/nF9VaZeZHMg+FQUikxvxbObuRMim 0WNoSS1QS5FqQDYkZxHl+HXvWTHivq5nydtcHItrnwiYc03tob/FrDTOjDsVJ7YVDNkv EHLP/fuR4N9a0DLfwXaGftVE+RUHD2cfV/1CbfVaTGA3vyXA6IMSK0r7n06K4uEVaEGy a4mBah7sN5ZcH9BPsELJkpm0NhXUrHUB0NxbWjGdoTz/81PAxotOiHp41CxMO0y6cOdo qYfw== MIME-Version: 1.0 X-Received: by 10.107.12.27 with SMTP id w27mr3064205ioi.10.1433494084671; Fri, 05 Jun 2015 01:48:04 -0700 (PDT) In-Reply-To: References: <201506050742 DOT t557ggR8019445 AT envy DOT delorie DOT com> Date: Fri, 5 Jun 2015 11:48:04 +0300 Message-ID: Subject: Re: dxe3gen patch From: "Ozkan Sezer (sezeroz AT gmail DOT com)" To: djgpp AT delorie DOT com Cc: DJ Delorie Content-Type: multipart/mixed; boundary=001a113f8e6ab4c8a50517c159fb Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --001a113f8e6ab4c8a50517c159fb Content-Type: text/plain; charset=UTF-8 On 6/5/15, Ozkan Sezer wrote: > On 6/5/15, DJ Delorie wrote: >> >> I'm not opposed to environment variables, but they're a bit messy in a >> unix environment (vs djgpp where we can ship djgpp.env with them ;). >> > > We can provide a sample dxe3gen.sh for it maybe? (more below) > >> If dxegen is built as a native djgpp program, it should be using the >> native djgpp tools (gcc, ld, etc). Yes? >> > > Of course, > >> If dxegen is cross built, it should note the target prefix (the >> i586-pc-djgpp- part) and change the defaults for the tools to have >> that prefix (i586-pc-djgpp-gcc, etc). We try to do this with the >> -DDXE_LD option. >> >> If we do both of these correctly, most users shouldn't need to >> override the defaults at all, and then it's not as big a deal that >> they're controlled with environment variables (or cleaner but harder >> command line options). >> >> I don't think it's right for us to *rely* on environment variables to >> provide correct *default* program names, though. >> > > How about the following patch, which extends the -DDXE_?? options > at cross-build time and also adds the DXE_?? environment stuff? > Or, do you prefer something without any environment vars? > >> >> Also, your mailer is wrapping lines, which corrupted the patch in a >> way that really confused me at first: >> >> /* Prepare the command line for ld */ >> new_argv = (const char **)malloc((argc - 1 + NUMBER_OF_LINKER_ARGS >> + NUMBER_OF_ADDITIONAL_LOADED_LIBS + 2 + 1) * sizeof(char *)); >> + process_env(); >> process_args(argc, argv, new_argv); >> >> Note the column for the wrapped '+' :-) > > Yeah, gmail is to blame. Attaching the patch too this time. > > Index: src/dxe/makefile > =================================================================== > RCS file: /cvs/djgpp/djgpp/src/dxe/makefile,v > retrieving revision 1.8 > diff -u -r1.8 makefile > --- src/dxe/makefile 21 Jul 2013 12:25:58 -0000 1.8 > +++ src/dxe/makefile 5 Jun 2015 08:18:18 -0000 > @@ -33,7 +33,7 @@ > $(EXE) > > $(HOSTBIN)/dxegen.exe : dxe3gen.c init1.h init2.h init3.h init4.h > init5.h fini1.h fini2.h fini3.h fini4.h fini5.h > - $(GCC) -DDXE_LD=\"$(CROSS_LD)\" dxe3gen.c -o $@ > + $(GCC) -DDXE_LD=\"$(CROSS_LD)\" -DDXE_CC=\"$(CROSS_GCC)\" > -DDXE_AR=\"$(CROSS_AR)\" -DDXE_AS=\"$(CROSS_AS)\" dxe3gen.c -o $@ > > clean :: > @-$(MISC) rm *.o *.h $(HOSTBIN)/dxegen.exe > Index: src/dxe/dxe3gen.c > =================================================================== > RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v > retrieving revision 1.20 > diff -u -r1.20 dxe3gen.c > --- src/dxe/dxe3gen.c 23 May 2015 08:20:05 -0000 1.20 > +++ src/dxe/dxe3gen.c 5 Jun 2015 08:18:18 -0000 > @@ -165,10 +165,23 @@ > #endif /* !DEBUG_SUPPORT_PRINT_RELOCATION_DIRECTIVES */ > > > +/* Cross compile tool names */ > +#ifndef DXE_CC > +#define DXE_CC "gcc" > +#endif > +#ifndef DXE_AS > +#define DXE_AS "as" > +#endif > +#ifndef DXE_AR > +#define DXE_AR "ar" > +#endif > #ifndef DXE_LD > -/* Cross compile ld name/location */ > #define DXE_LD "ld" > #endif > +#ifndef DXE_SC > +#define DXE_SC "dxe.ld" > +#endif > + > #ifdef _POSIX_SOURCE > /* Linux violates POSIX.1 and defines this, but it shouldn't.. */ > #undef _POSIX_SOURCE > @@ -297,6 +310,15 @@ > }; > > > +static char *libdir; > +/* build tools */ > +static char *dxe_cc; /* default: "gcc" */ > +static char *dxe_as; /* default: "as" */ > +static char *dxe_ar; /* default: "ar" */ > +static char *dxe_ld; /* default: "ld" */ > +/* linker script */ > +static char *dxe_sc; /* default: "dxe.ld" */ > + > > /* Desc: replaces backslash with slash in a path > * > @@ -410,6 +432,45 @@ > > > > +/* Desc: process the DXE_?? environment variables > + */ > +static void process_env(void) > +{ > + const char *e; > + > + if ((e = getenv("DXE_CC")) != NULL) > + dxe_cc = strdup(e); > + else dxe_cc = strdup(DXE_CC); > + > + if ((e = getenv("DXE_AS")) != NULL) > + dxe_as = strdup(e); > + else dxe_as = strdup(DXE_AS); > + > + if ((e = getenv("DXE_AR")) != NULL) > + dxe_ar = strdup(e); > + else dxe_ar = strdup(DXE_AR); > + > + if ((e = getenv("DXE_LD")) != NULL) > + dxe_ld = strdup(e); > + else dxe_ld = strdup(DXE_LD); > + > + if ((e = getenv("DXE_SC")) != NULL) > + dxe_sc = strdup(e); > + else dxe_sc = strdup(DXE_SC); > + > + if ((e = getenv("DXE_LD_LIBRARY_PATH")) != NULL) > + libdir = strdup(e); > + else if ((e = getenv("DJDIR")) != NULL) { > + size_t sz = strlen(e) + 5U; > + libdir = malloc(sz); > + strcpy(libdir, e); > + strcat(libdir, "/lib"); > + canonicalize_path(libdir); > + } > + else libdir = NULL; > +} > + > + > /* Desc: process command line args > * > * In : no of arguments, argument list, ptr to store linker args > @@ -419,30 +480,15 @@ > */ > static void process_args(int argc, char *argv[], const char *new_argv[]) > { > - static char libdir[FILENAME_MAX]; > - char *p; > int i, new_argc = NUMBER_OF_LINKER_ARGS; > > - p = getenv("DXE_LD_LIBRARY_PATH"); > - if (p) > - strcpy(libdir, p); > - else > + if (!libdir) > { > - p = getenv("DJDIR"); > - if (p) > - { > - strcpy(libdir, p); > - strcat(libdir, "/lib"); > - canonicalize_path(libdir); > - } > - else > - { > fprintf(stderr, "Error: neither DXE_LD_LIBRARY_PATH nor DJDIR > are set in environment\n"); > exit(1); > - } > } > > - new_argv[0] = DXE_LD; > + new_argv[0] = dxe_ld; > new_argv[1] = "-X"; > new_argv[2] = "-S"; > new_argv[3] = "-r"; > @@ -451,7 +497,7 @@ > new_argv[6] = "-L"; > new_argv[7] = libdir; > new_argv[8] = "-T"; > - new_argv[9] = "dxe.ld"; > + new_argv[9] = dxe_sc; > > if (!strcmp(base_name(argv[0]), "dxegen")) > /* invoked as `dxegen' */ > @@ -736,7 +782,7 @@ > if ((rv = my_spawn(argv)) != 0) > { > if (rv == -1) > - perror(DXE_LD); > + perror("ld"); > exit(rv); > } > > @@ -861,7 +907,7 @@ > if (rv) > { > if (rv == -1) > - perror(DXE_LD); > + perror("ld"); > exit(rv); > } > > @@ -1336,7 +1382,8 @@ > } > > /* Pre-compile the resolver's output. */ > - rv = system("gcc -o "TEMP_S_FILE" -O2 -S "TEMP_BASE".c"); > + sprintf(cmdbuf, "%s -o %s -O2 -S %s.c", dxe_cc, TEMP_S_FILE, > TEMP_BASE); > + rv = system(cmdbuf); > remove(TEMP_BASE".c"); > if (rv != 0) > { > @@ -1420,7 +1467,8 @@ > atexit(exit_cleanup); > > /* Allright, now run the assembler on the resulting file */ > - if ((rv = system("as -o "TEMP_O_FILE" "TEMP_S_FILE)) != 0) > + sprintf(cmdbuf, "%s -o %s %s", dxe_as, TEMP_O_FILE, TEMP_S_FILE); > + if ((rv = system(cmdbuf)) != 0) > { > if (rv == -1) > perror("as"); > @@ -1428,7 +1476,7 @@ > } > > /* Okey-dokey, let's stuff the object file into the archive */ > - sprintf(cmdbuf, "ar crs %s "TEMP_O_FILE, opt.implib); > + sprintf(cmdbuf, "%s crs %s "TEMP_O_FILE, dxe_ar, opt.implib); > if ((rv = system(cmdbuf)) != 0) > { > if (rv == -1) > @@ -1512,6 +1560,7 @@ > progname = argv[0]; > /* Prepare the command line for ld */ > new_argv = (const char **)malloc((argc - 1 + NUMBER_OF_LINKER_ARGS > + NUMBER_OF_ADDITIONAL_LOADED_LIBS + 2 + 1) * sizeof(char *)); > + process_env(); > process_args(argc, argv, new_argv); > > if (opt.showdep || opt.showexp || opt.showunres) > Index: src/makefile.def > =================================================================== > RCS file: /cvs/djgpp/djgpp/src/makefile.def,v > retrieving revision 1.5 > diff -u -r1.5 makefile.def > --- src/makefile.def 6 Feb 2003 10:40:24 -0000 1.5 > +++ src/makefile.def 5 Jun 2015 08:18:17 -0000 > @@ -26,6 +26,7 @@ > # For building distributed (djgpp) libraries and programs > CROSS_GCC = gcc > CROSS_AR = ar > +CROSS_AS = as > CROSS_LD = ld > CROSS_STRIP = strip > CROSS_BISON = bison > @@ -33,6 +34,7 @@ > # For building native programs (hostbin/*); assumes GNU versions > GCC = gcc -g > AR = ar > +AS = as > LD = ld > STRIP = strip > BISON = bison > @@ -47,6 +49,7 @@ > > CROSS_GCC = i586-pc-msdosdjgpp-gcc -pipe > CROSS_AR = i586-pc-msdosdjgpp-ar > +CROSS_AS = i586-pc-msdosdjgpp-as > CROSS_LD = i586-pc-msdosdjgpp-ld > CROSS_STRIP = i586-pc-msdosdjgpp-strip > CROSS_BISON = bison > @@ -56,6 +59,7 @@ > > GCC = gcc -g -O2 > AR = ar > +AS = as > LD = ld > STRIP = strip > BISON = bison > Sigh, the attached fixed one does actually compile. Comments? -- O.S. --001a113f8e6ab4c8a50517c159fb Content-Type: application/octet-stream; name="dxe3gen_2b.patch" Content-Disposition: attachment; filename="dxe3gen_2b.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 SW5kZXg6IHNyYy9tYWtlZmlsZS5kZWYKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2N2cy9kamdwcC9k amdwcC9zcmMvbWFrZWZpbGUuZGVmLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjUKZGlmZiAtdSAt cjEuNSBtYWtlZmlsZS5kZWYKLS0tIHNyYy9tYWtlZmlsZS5kZWYJNiBGZWIgMjAwMyAxMDo0MDoy NCAtMDAwMAkxLjUKKysrIHNyYy9tYWtlZmlsZS5kZWYJNSBKdW4gMjAxNSAwODo0MDoxMiAtMDAw MApAQCAtMjYsNiArMjYsNyBAQAogIyBGb3IgYnVpbGRpbmcgZGlzdHJpYnV0ZWQgKGRqZ3BwKSBs aWJyYXJpZXMgYW5kIHByb2dyYW1zCiBDUk9TU19HQ0MgPSBnY2MKIENST1NTX0FSID0gYXIKK0NS T1NTX0FTID0gYXMKIENST1NTX0xEID0gbGQKIENST1NTX1NUUklQID0gc3RyaXAKIENST1NTX0JJ U09OID0gYmlzb24KQEAgLTMzLDYgKzM0LDcgQEAKICMgRm9yIGJ1aWxkaW5nIG5hdGl2ZSBwcm9n cmFtcyAoaG9zdGJpbi8qKTsgYXNzdW1lcyBHTlUgdmVyc2lvbnMKIEdDQyA9IGdjYyAtZwogQVIg PSBhcgorQVMgPSBhcwogTEQgPSBsZAogU1RSSVAgPSBzdHJpcAogQklTT04gPSBia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zIC1vICJURU1QX09fRklMRSIgIlRFTVBfU19GSUxFKSkgIT0gMCkKKyAgc3ByaW50Zihj bWRidWYsICIlcyAtbyAlcyAlcyIsIGR4ZV9hcywgVEVNUF9PX0ZJTEUsIFRFTVBfU19GSUxFKTsK KyAgaWYgKChydiA9IHN5c3RlbShjbWRidWYpKSAhPSAwKQogICB7CiAgICAgaWYgKHJ2ID09IC0x KQogICAgICAgcGVycm9yKCJhcyIpOwpAQCAtMTQyOCw3ICsxNDc2LDcgQEAKICAgfQogCiAgIC8q IE9rZXktZG9rZXksIGxldCdzIHN0dWZmIHRoZSBvYmplY3QgZmlsZSBpbnRvIHRoZSBhcmNoaXZl ICovCi0gIHNwcmludGYoY21kYnVmLCAiYXIgY3JzICVzICJURU1QX09fRklMRSwgb3B0LmltcGxp Yik7CisgIHNwcmludGYoY21kYnVmLCAiJXMgY3JzICVzICJURU1QX09fRklMRSwgZHhlX2FyLCBv cHQuaW1wbGliKTsKICAgaWYgKChydiA9IHN5c3RlbShjbWRidWYpKSAhPSAwKQogICB7CiAgICAg aWYgKHJ2ID09IC0xKQpAQCAtMTUxMiw2ICsxNTYwLDcgQEAKICAgcHJvZ25hbWUgPSBhcmd2WzBd OwogICAvKiBQcmVwYXJlIHRoZSBjb21tYW5kIGxpbmUgZm9yIGxkICovCiAgIG5ld19hcmd2ID0g KGNvbnN0IGNoYXIgKiopbWFsbG9jKChhcmdjIC0gMSArIE5VTUJFUl9PRl9MSU5LRVJfQVJHUyAr IE5VTUJFUl9PRl9BRERJVElPTkFMX0xPQURFRF9MSUJTICsgMiArIDEpICogc2l6ZW9mKGNoYXIg KikpOworICBwcm9jZXNzX2VudigpOwogICBwcm9jZXNzX2FyZ3MoYXJnYywgYXJndiwgbmV3X2Fy Z3YpOwogCiAgIGlmIChvcHQuc2hvd2RlcCB8fCBvcHQuc2hvd2V4cCB8fCBvcHQuc2hvd3VucmVz KQo= --001a113f8e6ab4c8a50517c159fb--