Mail Archives: djgpp/2023/01/29/09:10:59
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
X-Recipient: | djgpp AT delorie DOT com
|
X-Original-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed;
|
| d=gmail.com; s=20210112;
|
| h=to:subject:message-id:date:from:references:in-reply-to:mime-version
|
| :from:to:cc:subject:date:message-id:reply-to;
|
| bh=Ia0abVdYJX+fTotYh4vQB+bpvQYRA3V8ugq8xsPnwIg=;
|
| b=SjQA6Dmxr+d+llty6Xwj09m57X5fgjp1zLxTjCpjV1WgJmd3hjzFav4DbYUA28aHjv
|
| sBD8/cLUZgAWvfckVNPUsMUPYPjQvL8L1PAj1SrwxXBriPncZDpAg1PBjgXa7vTIM5BM
|
| MhQh/oriyLoL9jInXlIpabAYrDEe9nbo1RNFkH+cnL7Ue8vuIHh3IqIhimvx5heIES8i
|
| TtRpxxTBe6rG8vb+5SxdrW3D9XWOldGH5cDFNo1omCwpv78OAqXcsrGeMQNl6N6YLQUF
|
| 9DHLYr6AceIBpNwwc5YFG0ctibQQ3DiU8BQURzAFErU73tWBrRdI6DzNoWydD5JiV1Uz
|
| J4mg==
|
X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed;
|
| d=1e100.net; s=20210112;
|
| h=to:subject:message-id:date:from:references:in-reply-to:mime-version
|
| :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
|
| bh=Ia0abVdYJX+fTotYh4vQB+bpvQYRA3V8ugq8xsPnwIg=;
|
| b=bDzA4O0FxnHIBvhminpZXmcMmPEg9/bI0qxVXBBscVjm10fURlgXuTId+EXMr1oZZd
|
| Nz+Im1Zxr2OgD/4VsP4hzhhlf4InvgcnTDns2q1FcnOLCNDbZ+9Xg7tmIRVN9Oi905Dm
|
| 7jRP/Um+dJkP8DSEzlznqw3wrQbEBTLdqoJuslXInUFlsTieB6WT3D3XrX9PvnYTlSaW
|
| IL+YXa/yhmCDD1hjopBfG0U5PRTh+PhM6VrYkF4tly3F3RgtC/mLtRXkxc/9hmQALETg
|
| wGX7jWfPZ6chLMiR17lAphIBEr2qqgcvgwnmyPIv++ENwz2VPcWRaj0vOOe/bWegHD/l
|
| zuzQ==
|
X-Gm-Message-State: | AFqh2koDvpwcpVU072nHLDWqXPJ1GT0UCjhHtY17t/1YpwwjM7GISMW3
|
| HSMou8bbF09lqVCGoQgEV6nwZrvNcGOdOSOnRiKM8imS
|
X-Google-Smtp-Source: | AMrXdXvp5ZjjODdL9aUPt1GkErrozY57TakbTVOL8Fo9Sm+GTPRWNYcxnxWCxvvsJ9182Rru6EI6A0mgizfTb3Gvu0I=
|
X-Received: | by 2002:a05:600c:5403:b0:3db:2fd:46b with SMTP id
|
| he3-20020a05600c540300b003db02fd046bmr2129993wmb.180.1675001265935; Sun, 29
|
| Jan 2023 06:07:45 -0800 (PST)
|
MIME-Version: | 1.0
|
In-Reply-To: | <83r0vd78cu.fsf@gnu.org>
|
References: | <d67303fd-c302-82cc-bb0d-d1a21640d66f AT gmail DOT com>
|
| <CAA2C=vDYkF13NYPP_EXGMwzrjhLj2vEq68+-uYPfZOXpqWVRfQ AT mail DOT gmail DOT com> <83r0vd78cu DOT fsf AT gnu DOT org>
|
From: | "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
|
Date: | Sun, 29 Jan 2023 17:07:45 +0300
|
Message-ID: | <CAA2C=vCCYsgtbQ5wsgbS3S4G7N+H5zi5DxCyVZLSkEKrSpifMw@mail.gmail.com>
|
Subject: | Re: [PATCH v3] dxe3gen: invoke ld/as via gcc
|
To: | djgpp AT delorie DOT com
|
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
|
On 1/29/23, Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com]
<djgpp AT delorie DOT com> wrote:
>> From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]"
>> <djgpp AT delorie DOT com>
>> Date: Sun, 29 Jan 2023 15:45:58 +0300
>>
>> How about the following suggestion?
>
> Is this really needed? IOW, can it really happen that the compiler
> fails to find libgcc unless explicitly told to look in the right
> directory?
gcc can, but ld can not: my suggested patch is not on top of JW's patch
it is against cvs where we invoke ld, not gcc. (Remember that the whole
purpose of JW's patch is that dxe3gen can find libgcc automatically w/o
any user effort..)
> If this is indeed needed, I don't object, but please make sure the new
> function works also in the cross-compilation setup, and finds the
> correct version of libgcc.
It does work in a cross- environment where I tested.
Further updated patch below, which increments the version too.
Index: dxe3gen.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v
retrieving revision 1.27
diff -u -p -r1.27 dxe3gen.c
--- dxe3gen.c 28 Jan 2023 14:10:03 -0000 1.27
+++ dxe3gen.c 29 Jan 2023 13:01:40 -0000
@@ -19,6 +19,7 @@
otherwise the exit code of GNU ld is returned
*/
+#include <limits.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -193,7 +194,7 @@
#include "../../include/sys/dxe.h"
#include "../../include/coff.h"
-#define VERSION "1.0.4"
+#define VERSION "1.0.5"
#define TEMP_BASE "dxe_tmp" /* 7 chars, 1 char suffix */
#define TEMP_O_FILE TEMP_BASE".o"
@@ -204,7 +205,7 @@
#define IS_SLASH(path) (((path) == '/') || ((path) == '\\'))
#define IS_DIR_SEPARATOR(path) (IS_SLASH(path) || ((path) == ':'))
-#define NUMBER_OF_LINKER_ARGS 10
+#define NUMBER_OF_LINKER_ARGS 12
#define NUMBER_OF_ADDITIONAL_LOADED_LIBS 0
#define IS_VALID_CIE(id) ((id) == 0)
@@ -465,6 +466,29 @@ static void process_env(void)
}
+#ifdef _WIN32
+#define popen _popen
+#define pclose _pclose
+#endif
+static char libgcc_dir[PATH_MAX];
+static void read_libgccdir(void)
+{
+ char *ptr;
+ FILE *p;
+
+ sprintf(libgcc_dir, "%s -print-libgcc-file-name", dxe_cc);
+ p = popen(libgcc_dir,"r");
+ memset(libgcc_dir, 0, sizeof(libgcc_dir));
+ if (!p) return;
+ while (fread(libgcc_dir, 1, sizeof(libgcc_dir), p) > 0) {
+ /**/;
+ }
+ pclose(p);
+ ptr = strrchr(libgcc_dir, '\\');
+ if (!ptr) ptr = strrchr(libgcc_dir, '/');
+ if (ptr) *ptr = '\0';
+}
+
/* Desc: process command line args
*
* In : no of arguments, argument list, ptr to store linker args
@@ -481,6 +505,12 @@ static void process_args(int argc, char
fprintf(stderr, "Error: neither DXE_LD_LIBRARY_PATH nor DJDIR are
set in environment\n");
exit(1);
}
+ read_libgccdir();
+ if (!libgcc_dir[0])
+ {
+ fprintf(stderr, "Error: failed determining libgcc directory\n");
+ exit(1);
+ }
new_argv[0] = dxe_ld;
new_argv[1] = "-X";
@@ -490,8 +520,10 @@ static void process_args(int argc, char
new_argv[5] = TEMP_O_FILE;
new_argv[6] = "-L";
new_argv[7] = libdir;
- new_argv[8] = "-T";
- new_argv[9] = dxe_sc;
+ new_argv[8] = "-L";
+ new_argv[9] = libgcc_dir;
+ new_argv[10] = "-T";
+ new_argv[11] = dxe_sc;
if (!strcmp(base_name(argv[0]), "dxegen"))
/* invoked as `dxegen' */
Index: makefile.dxe
===================================================================
RCS file: /cvs/djgpp/djgpp/src/dxe/makefile.dxe,v
retrieving revision 1.3
diff -u -p -r1.3 makefile.dxe
--- makefile.dxe 28 Jan 2023 14:10:04 -0000 1.3
+++ makefile.dxe 29 Jan 2023 14:01:40 -0000
@@ -10,6 +10,7 @@ CROSS_LD = $(CROSS_PREFIX)ld
CROSS_STRIP = $(CROSS_PREFIX)strip
CC = gcc
+HOST_CC = gcc
all: dxe3gen dxegen dxe3res
@@ -41,7 +42,7 @@ dxe3res: dxe3res.c
$(CC) -O2 -Wall dxe3res.c -o $@
bin2h.exe: ../utils/bin2h.c
- $(CC) ../utils/bin2h.c -o $@
+ $(HOST_CC) ../utils/bin2h.c -o $@
clean:
rm -f *.o *.h bin2h.exe dxegen dxe3gen dxe3res
- Raw text -