Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

fix Issue 22744 - ImportC: builtins defined in __builtins.di cause un… #3732

Merged
merged 1 commit into from Feb 8, 2022

Conversation

WalterBright
Copy link
Member

…defined symbol linker errors

Making them templates makes the import "header only".

@WalterBright WalterBright added Easy Review ImportC Pertaining to ImportC support labels Feb 8, 2022
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
22744 normal ImportC: builtins defined in __builtins.di cause undefined symbol linker errors.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3732"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Feb 8, 2022
@WalterBright
Copy link
Member Author

Test compilable/test6461.sh failed. The logged output:
 ... compilable\test67.d            ()
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `a.obj` has magic = 6202, should be 8664
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `a_1_149.obj` has magic = 6202, should be 8664
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `tmpl_2_309.obj` has magic = 6202, should be 8664
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `object_3_5ad.obj` has magic = 6202, should be 8664
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `object_4_9ff.obj` has magic = 6202, should be 8664
D:\a\1\dmd\test\test_results\compilable\test6461a.lib: Error: MS-Coff object module `object_5_5e9.obj` has magic = 6202, should be 8664

It makes no sense that this has anything to do with this PR.

@WalterBright
Copy link
Member Author

@RazvanN7 is there something else in druntime causing these errors?

@RazvanN7
Copy link
Contributor

RazvanN7 commented Feb 8, 2022

Do you have the latest version of druntime? @MoonlightSentinel has been doing some MS-Coff patches recently so there might be some branch checkout mismatches.

@WalterBright
Copy link
Member Author

trying a rebase...

@RazvanN7
Copy link
Contributor

RazvanN7 commented Feb 8, 2022

That seems to have fixed it. When in doubt, rebase...

@huglovefan
Copy link
Contributor

huglovefan commented Feb 8, 2022

this might be a separate issue but it still causes a link error if you use dmd -i (include-imports mode)

% cat main.c
int main() { double x = __builtin_inf(); }
% work/result/bin/dmd -run main.c
% work/result/bin/dmd -i -run main.c
ld.lld: error: undefined symbol: _D10__builtins__T13__builtin_infZQqFNaNbNiNfZd
>>> referenced by main.c
>>>               main.o:(main)
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1

same thing affects D code if you have templates in a .di file and use -i

edit: reported at https://issues.dlang.org/show_bug.cgi?id=22750

@dlang-bot dlang-bot merged commit 220e9e7 into dlang:master Feb 8, 2022
@WalterBright
Copy link
Member Author

@huglovefan as issue is not specific to this PR or ImportC, please file a bugzilla issue for it.

@WalterBright WalterBright deleted the builtin_inf branch February 8, 2022 19:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Fix Include reference to corresponding bugzilla issue Easy Review ImportC Pertaining to ImportC support
Projects
None yet
4 participants