Skip to content

Conversation

etcwilde
Copy link
Member

The swiftmodule isn't something the linker can operate on. It should be passed to the clang linker, but not to the underlying linker through the use of the linker input filelist.

This exposes itself as a linker error when trying to link with a filelist and debug info. With debug info, the driver schedules an emit-module job and an object compile job, which are both fed into the link job.

> swiftc hello.swift -g -emit-executable -driver-filelist-threshold=0 0: input, "hello.swift", swift 1: emit-module, {0}, swiftmodule 2: compile, {0}, object 3: link, {1, 2}, image 4: generate-dSYM, {3}, dSYM 

Without generating debug info, the driver does not schedule an emit-module job, so the swiftmodule is never generated in the first place and not included in the filelist where it can cause trouble.

> swiftc hello.swift -emit-executable -driver-filelist-threshold=0 0: input, "hello.swift", swift 1: compile, {0}, object 2: link, {1}, image 

I've removed the module from the linker filelist, but kept it in the module input list. This lines up more cleanly with the non-filelist path, which passes the swiftmodule to the clang-linker via a direct -Wl,-add_ast_path.

Fixes: rdar://125936639

The swiftmodule isn't something the linker can operate on. It should be passed to the clang linker, but not to the underlying linker through the use of the linker input filelist. This exposes itself as a linker error when trying to link with a filelist and debug info. With debug info, the driver schedules an `emit-module` job and an object compile job, which are both fed into the link job. > swiftc hello.swift -g -emit-executable -driver-filelist-threshold=0 0: input, "hello.swift", swift 1: emit-module, {0}, swiftmodule 2: compile, {0}, object 3: link, {1, 2}, image 4: generate-dSYM, {3}, dSYM Without generating debug info, the driver does not schedule an emit-module job, so the swiftmodule is never generated in the first place and not included in the filelist where it can cause trouble. > swiftc hello.swift -emit-executable -driver-filelist-threshold=0 0: input, "hello.swift", swift 1: compile, {0}, object 2: link, {1}, image I've removed the module from the linker filelist, but kept it in the module input list. This lines up more cleanly with the non-filelist path, which passes the swiftmodule to the clang-linker via a direct `-Wl,-add_ast_path`. Fixes: rdar://125936639
@etcwilde
Copy link
Member Author

@swift-ci please test

@etcwilde
Copy link
Member Author

@etcwilde etcwilde added the bug Something isn't working label Apr 15, 2024
@etcwilde etcwilde merged commit 6deb6fc into swiftlang:main Apr 15, 2024
@etcwilde etcwilde deleted the ewilde/remove-swiftmodule-from-linker-input branch April 15, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants