Skip to content

[Clang] Don't use crtbegin/crtend when building for musl. #8254

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
merged 1 commit into from
Mar 13, 2024

Conversation

al45tair
Copy link

musl doesn't supply crtbegin/crtend objects, so we don't want to try to link them there.

rdar://123436174

musl doesn't supply crtbegin/crtend objects, so we don't want to
try to link them there.

rdar://123436174
@al45tair
Copy link
Author

@swift-ci Please test

Copy link

@TNorthover TNorthover left a comment

Choose a reason for hiding this comment

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

Would obviously need tests before upstreaming.

Other than that, if musl doesn't have crtbegin how does it get from entry to main properly? I know Darwin's dyld does it but hadn't heard of the Linux loader taking those duties.

@al45tair
Copy link
Author

That's not what crtbegin.o and crtend.o are for. There's a useful page here that explains what all the object files are:

https://dev.gentoo.org/~vapier/crt.txt

It's crt1.o that's responsible for calling (eventually) main(). Musl is still using the "old-style" constructor/destructor system, hence it doesn't have crtbegin.o or crtend.o.

@al45tair al45tair requested a review from TNorthover February 28, 2024 13:31
Copy link

@TNorthover TNorthover left a comment

Choose a reason for hiding this comment

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

Fair enough. Think I was lumping all of those together in my mind.

@al45tair al45tair merged commit c924173 into swiftlang:stable/20230725 Mar 13, 2024
@drodriguez
Copy link

  Clang :: Driver/ohos.c
  Clang :: Driver/ohos.cpp

fail after these changes. For example: https://ci.swift.org/job/pr-apple-llvm-project-llvm-linux/232/

I tested with these changes reverted and the tests pass. With these changes the tests fail.

@al45tair
Copy link
Author

@drodriguez According to upstream LLVM, this is the wrong fix anyway, so let’s revert it.

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.

3 participants