-
-
Notifications
You must be signed in to change notification settings - Fork 15
Do not add any target-lib dependencies if not using phobos #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
With this patch applied, xtensa Hello World is looking good: object.d: module object;
class Object {} extern(C)
{
int printf(scope const char* format, ...);
void esp_restart();
alias TickType_t = ushort;
void vTaskDelay( const TickType_t xTicksToDelay );
}
enum configTICK_RATE_HZ = 100;
enum portTICK_PERIOD_MS = cast(TickType_t) 1000 / configTICK_RATE_HZ;
extern(C) void app_main()
{
printf("Hello from %s version %d!\n", __VENDOR__.ptr, __VERSION__);
for (int i = 10; i >= 0; i--) {
printf("Restarting in %d seconds...\n", i);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
printf("Restarting now.\n");
esp_restart();
} This runs a D FreeRTOS task on the ESP32 xtensa IOT chip 👍
@ibuclaw I guess I can still add some config support for |
Bootstrapping seems to be fine as well: https://buildkite.com/d-programming-gdc/gcc-test/builds/38#f5563eb4-e127-4973-84fe-7fc20e1a09b2 |
6a4b2f3
to
2211398
Compare
6956440
to
f57dbb1
Compare
gcc/d/config-lang.in
Outdated
# config-lang.in. So when using --disable-libphobos, it has not been | ||
# added to noconfigdirs here yet | ||
if eval test x\${enable_${libphobos}} "!=" xno ; then | ||
target_libs="target-libphobos target-zlib target-libbacktrace" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will also need to add noconfigdirs=target-zlib
if libphobos is disabled, so that it won't be built as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing. But where would enabling D have an effect on enabling target-zlib
? AFAICS there's Makefile.def
which makes target-libphobos
depend on target-zlib
, but if we disable target-libphobos
in configure.ac
/config-lang.in
the Makefile.def
dependencies should not have any effect. And I think in configure.ac
/config-lang.in
there's no code which should pull in target-zlib
, except for the target_libs
code which is already handled in this PR.
I just fear that if we explicitly add noconfigdirs=target-zlib
we might break builds where GCC depends on target-zlib
for some other reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a change I've only managed to get in last night: target-zlib
has been added back into top-level target_libraries
here: gcc-mirror/gcc@e60a24b#diff-67e997bcfdac55191033d57a16d1408a
This means that if the D front-end is not being built, it will be automatically added to noconfigdirs
. However if d/config-lang.in does not include target-zlib as a target_lib, then zlib will always be built, regardless of whether it's required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I understand: In configure.ac
, by default all libraries are enabled. configure.ac
then sources the config-lang.in
fragment and if the language is unsupported / disabled, it adds target_libs
to disabled_target_libs
and later to noconfigdirs
: https://github.com/gcc-mirror/gcc/blob/e60a24bda6d953531ffa7c02af296dad32603c2d/configure.ac#L2026 .
But this should also be a problem for target-libphobos
and target-libbacktrace
, I think? I suppose the best solution here is to add all libs to disabled_target_libs
instead in all cases where we do not set target_libs
: disabled_target_libs="$disabled_target_libs target-libphobos target-zlib target-libbacktrace"
.
We should probably not touch noconfigdirs
as libraries are only added to this if they are in disabled_target_libs
and not added to enabled_target_libs
by some other frontend: https://github.com/gcc-mirror/gcc/blob/e60a24bda6d953531ffa7c02af296dad32603c2d/configure.ac#L2060
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this should also be a problem for target-libphobos and target-libbacktrace, I think?
For target-libphobos, I think no, as if it's explicitly disabled, or unsupported, then the top-level configure will add it to noconfigdirs
. I don't think it will be pull in automatically, but I'll have to check that. :-)
target-libbacktrace is used by other front-ends, so leave it alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting disabled_target_libraries
.
- --enable-languages=c:
noconfigdirs=target-libphobos target-zlib target-libbacktrace
- --enable-languages=d:
noconfigdirs=target-libphobos target-zlib target-libbacktrace
- --enable-languages=d --disable-libphobos:
noconfigdirs=target-libphobos target-zlib target-libbacktrace
- --enable-languages=c --enable-libphobos:
noconfigdirs=target-libphobos target-zlib target-libbacktrace
By the way, the condition should be:
if eval test x${enable_libphobos} "!=" xno ; then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the condition should be:
if eval test x${enable_libphobos} "!=" xno ; then
Because I got some wrong results from the condition in some of the test vectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibuclaw your're right, there was an error in that if condition. I've pushed a new patch and I can reproduce your results, I think this is working properly now and most cases should have been tested:
no patch
supported
Flags | noconfigdirs |
---|---|
--enable-languages=c | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=d | gotools target-libgo |
--enable-languages=d --disable-libphobos | gotools target-libgo target-libphobos |
--enable-languages=c --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=c --enable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
unsupported
Flags | noconfigdirs |
---|---|
--enable-languages=c | target-libphobos gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=d | target-libphobos gotools target-libgo |
--enable-languages=d --disable-libphobos | gotools target-libgo target-libphobos |
--enable-languages=c --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=c --enable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
patch
supported
Flags | noconfigdirs |
---|---|
--enable-languages=c | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=d | gotools target-libgo |
--enable-languages=c,go | target-libphobos target-zlib |
-enable-languages=d,go --disable-libphobos | target-libphobos target-zlib |
--enable-languages=d --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=c --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace target-libphobos |
--enable-languages=c --enable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
unsupported
Flags | noconfigdirs |
---|---|
--enable-languages=c | target-libphobos gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=d | target-libphobos gotools target-libgo target-libphobos target-zlib target-libbacktrace |
--enable-languages=c,go | target-libphobos target-zlib |
--enable-languages=d --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace target-libphobos |
--enable-languages=c --disable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace target-libphobos |
--enable-languages=c --enable-libphobos | gotools target-libgo target-libphobos target-zlib target-libbacktrace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, apart from target-libphobos being added twice I guess.
I wonder if it might be better to have this in the top-level configure script though. I don't really have an opinion either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to not apply target-libphobos
twice. Doing this in the top-level configure would be more complicated: Removing libs from enabled_target_libs
is error prone. The other solution is to merge this into the code sourcing config-lang.in
, but that's supposed to be generic code and we would have to special-case d/config-lang.in
there.
The best solution would probably be to introduce a notion of dependecies for target-libs, then depend only on target-libphobos
. This would require some larger changes in configure.ac
though, and it's probably too late to do that for GCC9.
So can I post the patch to the ML? Is there anyone in particular I should CC?
07e9056
to
ccd517b
Compare
1cf2a98
to
605e7ae
Compare
93a02dd
to
5794a94
Compare
Committed as r270571. |
Prevents the following UBSAN error: ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/torture/pr49770.C -O2 -c /home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482:22: runtime error: load of value 2, which is not a valid value for type 'bool' #0 0x1fdb4d1 in modref_tree<int>::merge(modref_tree<int>*, vec<modref_parm_map, va_heap, vl_ptr>*) /home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482 #1 0x1fcadaa in merge_call_side_effects(modref_summary*, gimple*, modref_summary*, bool) /home/marxin/Programming/gcc2/gcc/ipa-modref.c:511 #2 0x1fcbadd in analyze_call /home/marxin/Programming/gcc2/gcc/ipa-modref.c:642 #3 0x1fcc061 in analyze_stmt /home/marxin/Programming/gcc2/gcc/ipa-modref.c:732 #4 0x1fccf31 in analyze_function /home/marxin/Programming/gcc2/gcc/ipa-modref.c:823 #5 0x1fd17e5 in execute /home/marxin/Programming/gcc2/gcc/ipa-modref.c:1441 #6 0x25cca6e in execute_one_pass(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2509 #7 0x25cd39b in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2597 #8 0x25cd450 in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2598 #9 0x25cd4ee in execute_pass_list(function*, opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2608 #10 0x25c7a5a in do_per_function_toporder(void (*)(function*, void*), void*) /home/marxin/Programming/gcc2/gcc/passes.c:1726 #11 0x25cfa3f in execute_ipa_pass_list(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2941 #12 0x173572d in ipa_passes /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2642 #13 0x17364ee in symbol_table::compile() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2777 #14 0x17372d9 in symbol_table::finalize_compilation_unit() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:3022 #15 0x2a1f00a in compile_file /home/marxin/Programming/gcc2/gcc/toplev.c:485 #16 0x2a27dc8 in do_compile /home/marxin/Programming/gcc2/gcc/toplev.c:2321 #17 0x2a283cc in toplev::main(int, char**) /home/marxin/Programming/gcc2/gcc/toplev.c:2460 #18 0x54f21cd in main /home/marxin/Programming/gcc2/gcc/main.c:39 #19 0x7ffff6f0de09 in __libc_start_main ../csu/libc-start.c:314 #20 0x9eac09 in _start (/home/marxin/Programming/gcc2/objdir/gcc/cc1plus+0x9eac09) gcc/ChangeLog: * ipa-modref.c (merge_call_side_effects): Clear modref_parm_map fields in the vector.
It fixes: /home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482:22: runtime error: load of value 255, which is not a valid value for type 'bool' #0 0x18e5df3 in modref_tree<int>::merge(modref_tree<int>*, vec<modref_parm_map, va_heap, vl_ptr>*) /home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482 #1 0x18dc180 in ipa_merge_modref_summary_after_inlining(cgraph_edge*) /home/marxin/Programming/gcc2/gcc/ipa-modref.c:1779 #2 0x18c1c72 in inline_call(cgraph_edge*, bool, vec<cgraph_edge*, va_heap, vl_ptr>*, int*, bool, bool*) /home/marxin/Programming/gcc2/gcc/ipa-inline-transform.c:492 #3 0x4a3589c in inline_small_functions /home/marxin/Programming/gcc2/gcc/ipa-inline.c:2216 #4 0x4a3b230 in ipa_inline /home/marxin/Programming/gcc2/gcc/ipa-inline.c:2697 #5 0x4a3d902 in execute /home/marxin/Programming/gcc2/gcc/ipa-inline.c:3096 #6 0x1edf831 in execute_one_pass(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2509 #7 0x1ee26af in execute_ipa_pass_list(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2936 #8 0x103f31b in ipa_passes /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2700 #9 0x103fb40 in symbol_table::compile() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2777 #10 0x104092b in symbol_table::finalize_compilation_unit() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:3022 #11 0x235723b in compile_file /home/marxin/Programming/gcc2/gcc/toplev.c:485 #12 0x235fff9 in do_compile /home/marxin/Programming/gcc2/gcc/toplev.c:2321 #13 0x23605fc in toplev::main(int, char**) /home/marxin/Programming/gcc2/gcc/toplev.c:2460 #14 0x4e2b93b in main /home/marxin/Programming/gcc2/gcc/main.c:39 #15 0x7ffff6f0ae09 in __libc_start_main ../csu/libc-start.c:314 #16 0x9a0be9 in _start (/home/marxin/Programming/gcc2/objdir/gcc/cc1+0x9a0be9) gcc/ChangeLog: * ipa-modref.c (compute_parm_map): Clear vector.
The fixed error is: ==21166==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x60300000d900 #0 0x7367d7 in operator delete(void*, unsigned long) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/libsanitizer/asan/asan_new_delete.cpp:172 #1 0x3b82e6e in pointer_equiv_analyzer::~pointer_equiv_analyzer() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/gimple-ssa-evrp.c:161 #2 0x3b83387 in hybrid_folder::~hybrid_folder() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/gimple-ssa-evrp.c:517 #3 0x3b83387 in execute_early_vrp /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/gimple-ssa-evrp.c:686 #4 0x1790611 in execute_one_pass(opt_pass*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:2567 #5 0x1792003 in execute_pass_list_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:2656 #6 0x1792029 in execute_pass_list_1 /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:2657 #7 0x179209f in execute_pass_list(function*, opt_pass*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:2667 #8 0x178a5f3 in do_per_function_toporder(void (*)(function*, void*), void*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:1773 #9 0x1792fac in do_per_function_toporder(void (*)(function*, void*), void*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/plugin.h:191 #10 0x1792fac in execute_ipa_pass_list(opt_pass*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/passes.c:3001 #11 0xc525fc in ipa_passes /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/cgraphunit.c:2154 #12 0xc525fc in symbol_table::compile() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/cgraphunit.c:2289 #13 0xc5a096 in symbol_table::compile() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/cgraphunit.c:2269 #14 0xc5a096 in symbol_table::finalize_compilation_unit() /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/cgraphunit.c:2537 #15 0x1a7a17c in compile_file /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/toplev.c:482 #16 0x69c758 in do_compile /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/toplev.c:2210 #17 0x69c758 in toplev::main(int, char**) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/toplev.c:2349 #18 0x6a932a in main /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/main.c:39 #19 0x7ffff7820b34 in __libc_start_main ../csu/libc-start.c:332 #20 0x6aa5fd in _start (/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/objdir/gcc/cc1+0x6aa5fd) 0x60300000d900 is located 0 bytes inside of 32-byte region [0x60300000d900,0x60300000d920) allocated by thread T0 here: #0 0x735ab7 in operator new[](unsigned long) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/libsanitizer/asan/asan_new_delete.cpp:102 #1 0x3b82dac in pointer_equiv_analyzer::pointer_equiv_analyzer(gimple_ranger*) /home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-asan/build/gcc/gimple-ssa-evrp.c:156 gcc/ChangeLog: * gimple-ssa-evrp.c (pointer_equiv_analyzer::~pointer_equiv_analyzer): Use delete[].
For aarch64, the alignment of the LTRAMPn symbols matters. Actually, the LTRAMPn symbols _are_ 8 byte aligned, but because they are Local, the linker doesn't know that this guarantee can be met. It assumes that they are not necessarily more aligned than the containing section (ld64 atoms strike again). The fix is to publish the trampoline symbol for the linker to access directly - it can then see that the atom is suitably aligned. Fixes issue #11 on the development branch. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Add LTRAMP to the list of symbol prefixes that must be made linker- visible.
…imize or target pragmas [PR103012] The following testcases ICE when an optimize or target pragma is followed by a long line (4096+ chars). This is because on such long lines we can't use columns anymore, but the cpp_define calls performed by c_cpp_builtins_optimize_pragma or from the backend hooks for target pragma are done on temporary buffers and expect to get columns from whatever line they appear on (which happens to be the long line after optimize/target pragma), and we run into: #0 fancy_abort (file=0x3abec67 "../../libcpp/line-map.c", line=502, function=0x3abecfc "linemap_add") at ../../gcc/diagnostic.c:1986 #1 0x0000000002e7c335 in linemap_add (set=0x7ffff7fca000, reason=LC_RENAME, sysp=0, to_file=0x41287a0 "pr103012.i", to_line=3) at ../../libcpp/line-map.c:502 #2 0x0000000002e7cc24 in linemap_line_start (set=0x7ffff7fca000, to_line=3, max_column_hint=128) at ../../libcpp/line-map.c:827 #3 0x0000000002e7ce2b in linemap_position_for_column (set=0x7ffff7fca000, to_column=1) at ../../libcpp/line-map.c:898 #4 0x0000000002e771f9 in _cpp_lex_direct (pfile=0x40c3b60) at ../../libcpp/lex.c:3592 #5 0x0000000002e76c3e in _cpp_lex_token (pfile=0x40c3b60) at ../../libcpp/lex.c:3394 #6 0x0000000002e610ef in lex_macro_node (pfile=0x40c3b60, is_def_or_undef=true) at ../../libcpp/directives.c:601 #7 0x0000000002e61226 in do_define (pfile=0x40c3b60) at ../../libcpp/directives.c:639 #8 0x0000000002e610b2 in run_directive (pfile=0x40c3b60, dir_no=0, buf=0x7fffffffd430 "__OPTIMIZE__ 1\n", count=14) at ../../libcpp/directives.c:589 #9 0x0000000002e650c1 in cpp_define (pfile=0x40c3b60, str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2513 #10 0x0000000002e65100 in cpp_define_unused (pfile=0x40c3b60, str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2522 #11 0x0000000000f50685 in c_cpp_builtins_optimize_pragma (pfile=0x40c3b60, prev_tree=<optimization_node 0x7fffea042000>, cur_tree=<optimization_node 0x7fffea042020>) at ../../gcc/c-family/c-cppbuiltin.c:600 assertion that LC_RENAME doesn't happen first. I think the right fix is emit those predefined macros upon optimize/target pragmas with BUILTINS_LOCATION, like we already do for those macros at the start of the TU, they don't appear in columns of the next line after it. Another possibility would be to force them at the location of the pragma. 2021-12-30 Jakub Jelinek <jakub@redhat.com> PR c++/103012 gcc/ * config/i386/i386-c.c (ix86_pragma_target_parse): Perform cpp_define/cpp_undef calls with forced token locations BUILTINS_LOCATION. * config/arm/arm-c.c (arm_pragma_target_parse): Likewise. * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Likewise. * config/s390/s390-c.c (s390_pragma_target_parse): Likewise. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Perform cpp_define_unused/cpp_undef calls with forced token locations BUILTINS_LOCATION. gcc/testsuite/ PR c++/103012 * g++.dg/cpp/pr103012.C: New test. * g++.target/i386/pr103012.C: New test.
…imize or target pragmas [PR103012] The following testcases ICE when an optimize or target pragma is followed by a long line (4096+ chars). This is because on such long lines we can't use columns anymore, but the cpp_define calls performed by c_cpp_builtins_optimize_pragma or from the backend hooks for target pragma are done on temporary buffers and expect to get columns from whatever line they appear on (which happens to be the long line after optimize/target pragma), and we run into: #0 fancy_abort (file=0x3abec67 "../../libcpp/line-map.c", line=502, function=0x3abecfc "linemap_add") at ../../gcc/diagnostic.c:1986 #1 0x0000000002e7c335 in linemap_add (set=0x7ffff7fca000, reason=LC_RENAME, sysp=0, to_file=0x41287a0 "pr103012.i", to_line=3) at ../../libcpp/line-map.c:502 #2 0x0000000002e7cc24 in linemap_line_start (set=0x7ffff7fca000, to_line=3, max_column_hint=128) at ../../libcpp/line-map.c:827 #3 0x0000000002e7ce2b in linemap_position_for_column (set=0x7ffff7fca000, to_column=1) at ../../libcpp/line-map.c:898 #4 0x0000000002e771f9 in _cpp_lex_direct (pfile=0x40c3b60) at ../../libcpp/lex.c:3592 #5 0x0000000002e76c3e in _cpp_lex_token (pfile=0x40c3b60) at ../../libcpp/lex.c:3394 #6 0x0000000002e610ef in lex_macro_node (pfile=0x40c3b60, is_def_or_undef=true) at ../../libcpp/directives.c:601 #7 0x0000000002e61226 in do_define (pfile=0x40c3b60) at ../../libcpp/directives.c:639 #8 0x0000000002e610b2 in run_directive (pfile=0x40c3b60, dir_no=0, buf=0x7fffffffd430 "__OPTIMIZE__ 1\n", count=14) at ../../libcpp/directives.c:589 #9 0x0000000002e650c1 in cpp_define (pfile=0x40c3b60, str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2513 #10 0x0000000002e65100 in cpp_define_unused (pfile=0x40c3b60, str=0x2f784d1 "__OPTIMIZE__") at ../../libcpp/directives.c:2522 #11 0x0000000000f50685 in c_cpp_builtins_optimize_pragma (pfile=0x40c3b60, prev_tree=<optimization_node 0x7fffea042000>, cur_tree=<optimization_node 0x7fffea042020>) at ../../gcc/c-family/c-cppbuiltin.c:600 assertion that LC_RENAME doesn't happen first. I think the right fix is emit those predefined macros upon optimize/target pragmas with BUILTINS_LOCATION, like we already do for those macros at the start of the TU, they don't appear in columns of the next line after it. Another possibility would be to force them at the location of the pragma. 2021-12-30 Jakub Jelinek <jakub@redhat.com> PR c++/103012 gcc/ * config/i386/i386-c.c (ix86_pragma_target_parse): Perform cpp_define/cpp_undef calls with forced token locations BUILTINS_LOCATION. * config/arm/arm-c.c (arm_pragma_target_parse): Likewise. * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Likewise. * config/s390/s390-c.c (s390_pragma_target_parse): Likewise. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Perform cpp_define_unused/cpp_undef calls with forced token locations BUILTINS_LOCATION. gcc/testsuite/ PR c++/103012 * g++.dg/cpp/pr103012.C: New test. * g++.target/i386/pr103012.C: New test. (cherry picked from commit 1dbe26b)
For aarch64, the alignment of the LTRAMPn symbols matters. Actually, the LTRAMPn symbols _are_ 8 byte aligned, but because they are Local, the linker doesn't know that this guarantee can be met. It assumes that they are not necessarily more aligned than the containing section (ld64 atoms strike again). The fix is to publish the trampoline symbol for the linker to access directly - it can then see that the atom is suitably aligned. Fixes issue #11 on the development branch. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Add LTRAMP to the list of symbol prefixes that must be made linker- visible. (cherry picked from commit f1e2879)
For aarch64, the alignment of the LTRAMPn symbols matters. Actually, the LTRAMPn symbols _are_ 8 byte aligned, but because they are Local, the linker doesn't know that this guarantee can be met. It assumes that they are not necessarily more aligned than the containing section (ld64 atoms strike again). The fix is to publish the trampoline symbol for the linker to access directly - it can then see that the atom is suitably aligned. Fixes issue #11 on the development branch. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Add LTRAMP to the list of symbol prefixes that must be made linker- visible. (cherry picked from commit f1e2879)
@ibuclaw I'm currently trying to see how well GDC builds for bare-metal targets without phobos, I'd like to have gdc at least compile and 'hello-world' usable for ARM, AVR8, MSP430 and xtensa. I've started with xtensa but immediately ran into an old problem:
Even if we disable libphobos (as unsupported in configure.ac or using --disable-libphobos),
config-lang.in
still addstarget-libbacktrace
to thetarget_libs
. On some embedded toolchains, libbacktrace however fails to build:This can't even be worked around:
--disable-libbacktrace
also disables the host libbacktrace and GCC does not build without a host libbacktrace.--disable-target-libbacktrace
is not supported.Even though maybe libbacktrace should be fixed as well, I'd prefer for a no-phobos gdc build to behave exactly like a normal gcc build. Adding
d
to the languages list should not cause any build failures.This patch adds some code to
config-lang.in
to check if phobos has been disabled (explicitly or as unsupported) and keeps thetarget_libs
unchanged in that case.