Skip to content

Remove swiftmodule from linker filelist input #1581

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

Merged

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

See also: swiftlang/swift#68947

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants