* [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
@ 2015-11-10 18:16 Andris Pavenis
2015-11-10 21:20 ` Jeff Law
2015-11-13 6:40 ` Jeff Law
0 siblings, 2 replies; 6+ messages in thread
From: Andris Pavenis @ 2015-11-10 18:16 UTC (permalink / raw)
To: GCC Patches, DJ Delorie
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
One may need to execute extra steps after linking program. This is required
for example for DJGPP to run stubify.exe on file generated by linker.
The only way how to achieve was to use LINK_COMMAND_SPEC. It would be much easier
and less error prone to use new macro POST_LINK_SPEC introduced in this patch.
Andris
ChangeLog entry
2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
* gcc.c: new macro POST_LINK_SPEC
* doc/tm.texi.in: document POST_LINK_SPEC
* doc/tm.texi: regenerate
[-- Attachment #2: 0001-New-macro-POST_LINK_SPEC.patch --]
[-- Type: text/x-patch, Size: 3437 bytes --]
From 2b50898ca2340aa43ce756bd605862b947cf1e7d Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
Date: Tue, 10 Nov 2015 19:52:57 +0200
Subject: [PATCH] New macro POST_LINK_SPEC for additional steps after rinning
linker
---
gcc/doc/tm.texi | 5 +++++
gcc/doc/tm.texi.in | 5 +++++
gcc/gcc.c | 8 +++++++-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f394db7..fe4e7f0 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -375,6 +375,11 @@ The sequence in which libgcc and libc are specified to the linker.
By default this is @code{%G %L %G}.
@end defmac
+@defmac POST_LINK_SPEC
+Define this macro to add additional steps to be executed after linker.
+The default value of this macro is empty string.
+@end defmac
+
@defmac LINK_COMMAND_SPEC
A C string constant giving the complete command line need to execute the
linker. When you do this, you will need to update your port each time a
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index d188c57..8c9c1b2 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -375,6 +375,11 @@ The sequence in which libgcc and libc are specified to the linker.
By default this is @code{%G %L %G}.
@end defmac
+@defmac POST_LINK_SPEC
+Define this macro to add additional steps to be executed after linker.
+The default value of this macro is empty string.
+@end defmac
+
@defmac LINK_COMMAND_SPEC
A C string constant giving the complete command line need to execute the
linker. When you do this, you will need to update your port each time a
diff --git a/gcc/gcc.c b/gcc/gcc.c
index bbc9b23..45d6089 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -979,6 +979,10 @@ proper position among the other output files. */
%{%:sanitize(leak):" LIBLSAN_SPEC "}}}"
#endif
+#ifndef POST_LINK_SPEC
+#define POST_LINK_SPEC ""
+#endif
+
/* This is the spec to use, once the code for creating the vtable
verification runtime library, libvtv.so, has been created. Currently
the vtable verification runtime functions are in libstdc++, so we use
@@ -1021,7 +1025,7 @@ proper position among the other output files. */
%(mflib) " STACK_SPLIT_SPEC "\
%{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
- %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
+ %{!nostdlib:%{!nostartfiles:%E}} %{T*} \n%(post_link) }}}}}}"
#endif
#ifndef LINK_LIBGCC_SPEC
@@ -1063,6 +1067,7 @@ static const char *linker_name_spec = LINKER_NAME;
static const char *linker_plugin_file_spec = "";
static const char *lto_wrapper_spec = "";
static const char *lto_gcc_spec = "";
+static const char *post_link_spec = POST_LINK_SPEC;
static const char *link_command_spec = LINK_COMMAND_SPEC;
static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC;
@@ -1571,6 +1576,7 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec),
INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec),
INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec),
+ INIT_STATIC_SPEC ("post_link", &post_link_spec),
INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec),
INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix),
INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix),
--
2.4.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
2015-11-10 18:16 [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking Andris Pavenis
@ 2015-11-10 21:20 ` Jeff Law
2015-11-11 4:30 ` Andris Pavenis
2015-11-13 6:40 ` Jeff Law
1 sibling, 1 reply; 6+ messages in thread
From: Jeff Law @ 2015-11-10 21:20 UTC (permalink / raw)
To: Andris Pavenis, GCC Patches, DJ Delorie
On 11/10/2015 11:16 AM, Andris Pavenis wrote:
> One may need to execute extra steps after linking program. This is required
> for example for DJGPP to run stubify.exe on file generated by linker.
>
> The only way how to achieve was to use LINK_COMMAND_SPEC. It would be
> much easier
> and less error prone to use new macro POST_LINK_SPEC introduced in this
> patch.
>
> Andris
>
> ChangeLog entry
>
> 2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
>
> * gcc.c: new macro POST_LINK_SPEC
> * doc/tm.texi.in: document POST_LINK_SPEC
> * doc/tm.texi: regenerate
>
Can you also include the changes to djgpp.h which exploit this capability?
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
2015-11-10 21:20 ` Jeff Law
@ 2015-11-11 4:30 ` Andris Pavenis
2015-11-13 6:41 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Andris Pavenis @ 2015-11-11 4:30 UTC (permalink / raw)
To: Jeff Law, GCC Patches, DJ Delorie
[-- Attachment #1: Type: text/plain, Size: 2197 bytes --]
On 11/10/2015 11:20 PM, Jeff Law wrote:
> On 11/10/2015 11:16 AM, Andris Pavenis wrote:
>> One may need to execute extra steps after linking program. This is required
>> for example for DJGPP to run stubify.exe on file generated by linker.
>>
>> The only way how to achieve was to use LINK_COMMAND_SPEC. It would be
>> much easier
>> and less error prone to use new macro POST_LINK_SPEC introduced in this
>> patch.
>>
>> Andris
>>
>> ChangeLog entry
>>
>> 2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
>>
>> * gcc.c: new macro POST_LINK_SPEC
>> * doc/tm.texi.in: document POST_LINK_SPEC
>> * doc/tm.texi: regenerate
>>
> Can you also include the changes to djgpp.h which exploit this capability?
>
> Jeff
OK. I'm only sending changes for djgpp.h. There are required changes to other files not included,
so djgpp.h patch currently
to illustrate use of POST_LINK_SPEC only not committing.
In short:
- earlier entire LINK_COMMAND_SPEC was redefined in djgpp.h (copy/paste from trunk)
#undef LINK_COMMAND_SPEC
#define LINK_COMMAND_SPEC \
"%{!fsyntax-only: \
%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l " LINK_COMPRESS_DEBUG_SPEC \
"%X %{o*} %{e*} %{N} %{n} \
\t%{r} %{s} %{t} %{u*} %{z} %{Z}\
\t%{!nostdlib:%{!nostartfiles:%S}}\
\t%{static:} %{L*} %D %o\
\t%{!nostdlib:%{!nodefaultlibs:%G %L %G}}\
\t%{!nostdlib:%{!nostartfiles:%E}}\
\t-Tdjgpp.djl %{T*}}}}}}}\n\
%{!c:%{!M:%{!MM:%{!E:%{!S:stubify %{v} %{o*:%*} %{!o*:a.out} }}}}}"
One needed to update it each time when LINK_COMMAND_SPEC changes in gcc.c
- use of linker script djgpp.djl has actually done long ago (mentioned in comments for
LINK_COMMAND_SPEC override). The other reason: running stubify after linker has remain
- in new version I only need
#undef POST_LINK_SPEC
#define POST_LINK_SPEC "stubify %{v} %{o*:%*} %{!o*:a.out}"
instead, which is much simpler.
About DJGPP related changes accumulated in rather many years. There were changes to generic files
which are highly
unlikely to be accepted (like use #ifdef __DJGPP__ in system independent files). I have to remove
such ifdefs from
system independent files and re-implement it differently where possible. That will take some time
and testing
Andris
[-- Attachment #2: djgpp_h_DONT_COMMIT.diff --]
[-- Type: text/x-patch, Size: 7192 bytes --]
diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h
index f8b9031..f3033f7 100644
--- a/gcc/config/i386/djgpp.h
+++ b/gcc/config/i386/djgpp.h
@@ -17,12 +17,27 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#define DBX_DEBUGGING_INFO 1
+#define SDB_DEBUGGING_INFO 1
+
/* Support generation of DWARF2 debugging info. */
#define DWARF2_DEBUGGING_INFO 1
+/* Use DWARF2 debugging info by default: comment out following */
+/* 2 lines to default to COFF debugging info */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+
/* Don't assume anything about the header files. */
#define NO_IMPLICIT_EXTERN_C
+/* If defined, a C expression whose value is a string containing the
+ assembler operation to identify the following data as
+ uninitialized global data. If not defined, and neither
+ `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
+ uninitialized global data will be output in the data section if
+ `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
+ used. */
#undef BSS_SECTION_ASM_OP
#define BSS_SECTION_ASM_OP "\t.section\t.bss"
@@ -30,6 +45,10 @@ along with GCC; see the file COPYING3. If not see
#undef DATA_SECTION_ASM_OP
#define DATA_SECTION_ASM_OP "\t.section .data"
+/* Define the name of the .ident op. */
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
+
/* Enable alias attribute support. */
#ifndef SET_ASM_OP
#define SET_ASM_OP "\t.set\t"
@@ -39,56 +58,26 @@ along with GCC; see the file COPYING3. If not see
#undef TEXT_SECTION_ASM_OP
#define TEXT_SECTION_ASM_OP "\t.section .text"
-/* Define standard DJGPP installation paths. */
-/* We override default /usr or /usr/local part with /dev/env/DJDIR which */
-/* points to actual DJGPP installation directory. */
-
-/* Search for as.exe and ld.exe in DJGPP's binary directory. */
-#undef MD_EXEC_PREFIX
-#define MD_EXEC_PREFIX "/dev/env/DJDIR/bin/"
-
-/* Standard DJGPP library and startup files */
-#undef MD_STARTFILE_PREFIX
-#define MD_STARTFILE_PREFIX "/dev/env/DJDIR/lib/"
-
-/* Correctly handle absolute filename detection in cp/xref.c */
-#define FILE_NAME_ABSOLUTE_P(NAME) \
- (((NAME)[0] == '/') || ((NAME)[0] == '\\') || \
- (((NAME)[0] >= 'A') && ((NAME)[0] <= 'z') && ((NAME)[1] == ':')))
-
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
+ if (!flag_iso) \
+ builtin_define_with_int_value ("DJGPP",2); \
+ builtin_define_with_int_value ("__DJGPP",2); \
+ builtin_define_with_int_value ("__DJGPP__",2); \
builtin_define_std ("MSDOS"); \
builtin_define_std ("GO32"); \
+ builtin_define_std ("unix"); \
builtin_assert ("system=msdos"); \
} \
while (0)
/* Include <sys/version.h> so __DJGPP__ and __DJGPP_MINOR__ are defined. */
#undef CPP_SPEC
-#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \
- -imacros %s../include/sys/version.h"
-
-/* We need to override link_command_spec in gcc.c so support -Tdjgpp.djl.
- This cannot be done in LINK_SPECS as that LINK_SPECS is processed
- before library search directories are known by the linker.
- This avoids problems when specs file is not available. An alternate way,
- suggested by Robert Hoehne, is to use SUBTARGET_EXTRA_SPECS instead.
-*/
-
-#undef LINK_COMMAND_SPEC
-#define LINK_COMMAND_SPEC \
-"%{!fsyntax-only: \
-%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l " LINK_COMPRESS_DEBUG_SPEC \
-"%X %{o*} %{e*} %{N} %{n} \
-\t%{r} %{s} %{t} %{u*} %{z} %{Z}\
-\t%{!nostdlib:%{!nostartfiles:%S}}\
-\t%{static:} %{L*} %D %o\
-\t%{!nostdlib:%{!nodefaultlibs:%G %L %G}}\
-\t%{!nostdlib:%{!nostartfiles:%E}}\
-\t-Tdjgpp.djl %{T*}}}}}}}\n\
-%{!c:%{!M:%{!MM:%{!E:%{!S:stubify %{v} %{o*:%*} %{!o*:a.out} }}}}}"
+#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE}"
+
+#undef POST_LINK_SPEC
+#define POST_LINK_SPEC "stubify %{v} %{o*:%*} %{!o*:a.out}"
/* Always just link in 'libc.a'. */
#undef LIB_SPEC
@@ -98,12 +87,8 @@ along with GCC; see the file COPYING3. If not see
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:crt0.o%s}"
-/* Make sure that gcc will not look for .h files in /usr/local/include
- unless user explicitly requests it. */
-#undef LOCAL_INCLUDE_DIR
-
/* Switch into a generic section. */
-#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
+#define TARGET_ASM_NAMED_SECTION i386_djgpp_asm_named_section
/* This is how to output an assembler line
that says to advance the location counter
@@ -129,7 +114,7 @@ along with GCC; see the file COPYING3. If not see
while (0)
#endif
-/* This is how to tell assembler that a symbol is weak */
+/* This is how to tell assembler that a symbol is weak */
#undef ASM_WEAKEN_LABEL
#define ASM_WEAKEN_LABEL(FILE,NAME) \
do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
@@ -159,23 +144,38 @@ along with GCC; see the file COPYING3. If not see
#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE "int"
-/* Used to be defined in xm-djgpp.h, but moved here for cross-compilers. */
-#define LIBSTDCXX "stdcxx"
-
-/* Warn that -mbnu210 is now obsolete. */
-#undef SUBTARGET_OVERRIDE_OPTIONS
-#define SUBTARGET_OVERRIDE_OPTIONS \
-do \
- { \
- if (TARGET_BNU210) \
- { \
- warning (0, "-mbnu210 is ignored (option is obsolete)"); \
- } \
- } \
-while (0)
-
/* Support for C++ templates. */
#undef MAKE_DECL_ONE_ONLY
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define IX86_MAYBE_NO_LIBGCC_TFMODE
+#undef DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(n) svr4_dbx_register_map[n]
+
+/* Default to pcc-struct-return. */
+#define DEFAULT_PCC_STRUCT_RETURN 1
+
+/* Ignore (with warning) -fPIC for DJGPP */
+#undef SUBTARGET_OVERRIDE_OPTIONS
+#define SUBTARGET_OVERRIDE_OPTIONS \
+ do { \
+ if (flag_pic) \
+ { \
+ fnotice(stdout, "-f%s ignored (not supported for DJGPP)\n", \
+ (flag_pic > 1) ? "PIC" : "pic"); \
+ flag_pic = 0; \
+ } \
+ \
+ /* Don't emit DWARF3/4 unless specifically selected. */ \
+ /* DWARF3/4 currently does not work for DJGPP. */ \
+ if (!global_options_set.x_dwarf_version) \
+ dwarf_version = 2; \
+ \
+ } \
+ while (0)
+
+/* Function protypes for gcc/i486/djgpp.c */
+
+void
+i386_djgpp_asm_named_section(const char *name, unsigned int flags,
+ tree decl);
+
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
2015-11-10 18:16 [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking Andris Pavenis
2015-11-10 21:20 ` Jeff Law
@ 2015-11-13 6:40 ` Jeff Law
2015-11-15 8:28 ` Andris Pavenis
1 sibling, 1 reply; 6+ messages in thread
From: Jeff Law @ 2015-11-13 6:40 UTC (permalink / raw)
To: Andris Pavenis, GCC Patches, DJ Delorie
On 11/10/2015 11:16 AM, Andris Pavenis wrote:
> One may need to execute extra steps after linking program. This is required
> for example for DJGPP to run stubify.exe on file generated by linker.
>
> The only way how to achieve was to use LINK_COMMAND_SPEC. It would be
> much easier
> and less error prone to use new macro POST_LINK_SPEC introduced in this
> patch.
>
> Andris
>
> ChangeLog entry
>
> 2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
>
> * gcc.c: new macro POST_LINK_SPEC
> * doc/tm.texi.in: document POST_LINK_SPEC
> * doc/tm.texi: regenerate
Instaled with a better ChangeLog. Presumably there's going to be a
followup to simplify a bunch of hte djgpp configuration?
jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
2015-11-11 4:30 ` Andris Pavenis
@ 2015-11-13 6:41 ` Jeff Law
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2015-11-13 6:41 UTC (permalink / raw)
To: Andris Pavenis, GCC Patches, DJ Delorie
On 11/10/2015 09:30 PM, Andris Pavenis wrote:
> On 11/10/2015 11:20 PM, Jeff Law wrote:
>> On 11/10/2015 11:16 AM, Andris Pavenis wrote:
>>> One may need to execute extra steps after linking program. This is
>>> required
>>> for example for DJGPP to run stubify.exe on file generated by linker.
>>>
>>> The only way how to achieve was to use LINK_COMMAND_SPEC. It would be
>>> much easier
>>> and less error prone to use new macro POST_LINK_SPEC introduced in this
>>> patch.
>>>
>>> Andris
>>>
>>> ChangeLog entry
>>>
>>> 2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
>>>
>>> * gcc.c: new macro POST_LINK_SPEC
>>> * doc/tm.texi.in: document POST_LINK_SPEC
>>> * doc/tm.texi: regenerate
>>>
>> Can you also include the changes to djgpp.h which exploit this
>> capability?
>>
>> Jeff
>
> OK. I'm only sending changes for djgpp.h. There are required changes to
> other files not included, so djgpp.h patch currently
> to illustrate use of POST_LINK_SPEC only not committing.
Thanks. I think the key is that y'all have to essentially duplicate and
hack of LINK_COMMAND_SPEC and this change allows the djgpp port to avoid
that problem.
Thanks again,
Jeff
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking
2015-11-13 6:40 ` Jeff Law
@ 2015-11-15 8:28 ` Andris Pavenis
0 siblings, 0 replies; 6+ messages in thread
From: Andris Pavenis @ 2015-11-15 8:28 UTC (permalink / raw)
To: Jeff Law, GCC Patches, DJ Delorie
On 11/13/2015 08:40 AM, Jeff Law wrote:
> On 11/10/2015 11:16 AM, Andris Pavenis wrote:
>> One may need to execute extra steps after linking program. This is required
>> for example for DJGPP to run stubify.exe on file generated by linker.
>>
>> The only way how to achieve was to use LINK_COMMAND_SPEC. It would be
>> much easier
>> and less error prone to use new macro POST_LINK_SPEC introduced in this
>> patch.
>>
>> Andris
>>
>> ChangeLog entry
>>
>> 2015 Nov 10 Andris Pavenis <andris.pavenis@iki.fi>
>>
>> * gcc.c: new macro POST_LINK_SPEC
>> * doc/tm.texi.in: document POST_LINK_SPEC
>> * doc/tm.texi: regenerate
> Instaled with a better ChangeLog. Presumably there's going to be a followup to simplify a bunch
> of hte djgpp configuration?
>
> jeff
>
>
>
There are large number of changes in djgpp related configuration files accumulated over many years.
Some cleanup and
verification whether all is still needed and and of course testing of both cross- and native
compiler is required.
It would be rather difficult to split it into parts. I'll going to submit configuration changes for
DJGPP
(gcc/config.host + gcc/config/i386/*djgpp*) in one large patch after cleanup and testing unless
there are objections.
Therefore small small separate changes can be expected first.
Andris
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-15 8:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 18:16 [PATCH] gcc.c: new macro POST_LINK_SPECS to be able to add additional steps after linking Andris Pavenis
2015-11-10 21:20 ` Jeff Law
2015-11-11 4:30 ` Andris Pavenis
2015-11-13 6:41 ` Jeff Law
2015-11-13 6:40 ` Jeff Law
2015-11-15 8:28 ` Andris Pavenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).