Skip to content

Specify "-rtlib=compiler-rt" on Linux as required for some of Swift's numeric conversion symbols. #1259

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

Closed
wants to merge 1 commit into from

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jan 12, 2023

Resolves rdar://104134160

@artemcm
Copy link
Contributor Author

artemcm commented Jan 12, 2023

@swift-ci test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@artemcm
Copy link
Contributor Author

artemcm commented Jan 12, 2023

Looks like it may be causing a test failure on Linux on main:
https://ci.swift.org/job/swift-PR-Linux/5421/console

error: link command failed with exit code 1 (use -v to see invocation)
/home/build-user/build/buildbot_linux/none-swift_package_sandbox_linux-x86_64/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::withCurrentBacktrace(std::function<void (void**, int)>): error: undefined reference to '_Unwind_Backtrace'
/home/build-user/build/buildbot_linux/none-swift_package_sandbox_linux-x86_64/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::printCurrentBacktrace(unsigned int): error: undefined reference to '_Unwind_Backtrace'
/home/build-user/build/buildbot_linux/none-swift_package_sandbox_linux-x86_64/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function SwiftUnwindFrame(_Unwind_Context*, void*): error: undefined reference to '_Unwind_GetIP'
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

error: command failed with exit status: 1

@eeckstein
Copy link
Contributor

@mikeash When linking with the clang rt, can this be solved by removing the #elif defined(__ELF__) case in withCurrentBacktraceImpl?

@mikeash
Copy link
Contributor

mikeash commented Jan 13, 2023

I think so. /cc @al45tair who would know better than I.

@al45tair
Copy link
Contributor

Does that not just mean that we also need -lunwind?

@bnbarham
Copy link
Contributor

bnbarham commented Jan 13, 2023

Could we instead make this change when building Clang? Ie. set CLANG_DEFAULT_RTLIB and CLANG_DEFAULT_UNWINDLIB (which both default to libgcc but we could instead have compiler-rt and libunwind respectively).

@artemcm
Copy link
Contributor Author

artemcm commented Jan 13, 2023

Could we instead make this change when building Clang? Ie. set CLANG_DEFAULT_RTLIB and CLANG_DEFAULT_UNWINDLIB (which both default to libgcc but we could instead have compiler-rt and libunwind respectively).

If this achieves the same thing (clang linker driver defaulting to rtlib=compiler-rt) then I'd be in favor of this approach also. But I'll let others weigh in.

@bnbarham
Copy link
Contributor

If this achieves the same thing (clang linker driver defaulting to rtlib=compiler-rt) then I'd be in favor of this approach also. But I'll let others weigh in.

@al45tair / @mikeash any thoughts?

@al45tair
Copy link
Contributor

I have no problem with it either way, as long as it works :-)

I think it might be slightly cleaner to configure Clang, if that way will work, not least because then we won't have oddities like things built with our Clang linking with libgcc but things built with Swift itself linking with libcompiler-rt and libunwind.

@compnerd
Copy link
Member

Accidentally linking libgcc would be a problem - libgcc is an unwinder, and mixing unwinders will lead to crashes as the context is implementation defined.

… numeric conversion symbols.

Resolves rdar://104134160
@artemcm
Copy link
Contributor Author

artemcm commented Jan 17, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 19, 2023

Re-running cross-repo tests in swiftlang/swift#60581, but from what I saw last time, adding -lunwind does not help with failing test-cases in main CI if this is merged. So this PR cannot be merged in its current form.

@bnbarham
Copy link
Contributor

Re-running cross-repo tests in swiftlang/swift#60581, but from what I saw last time, adding -lunwind does not help with failing test-cases in main CI if this is merged. So this PR cannot be merged in its current form.

IIUC we then had failures because of missing unwind errors instead.

@artemcm artemcm closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants