Skip to content
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

Mark start/stop sections as SHF_GNU_RETAIN #67476

Closed
wants to merge 1 commit into from

Conversation

keith
Copy link
Member

@keith keith commented Jul 22, 2023

@keith
Copy link
Member Author

keith commented Jul 22, 2023

@swift-ci Please test Linux platform

@MaxDesiatov MaxDesiatov requested review from etcwilde and al45tair July 22, 2023 20:03
@MaxDesiatov
Copy link
Contributor

@swift-ci build toolchain

keith added a commit to swiftlang/swift-driver that referenced this pull request Jul 22, 2023
keith added a commit to swiftlang/swift-driver that referenced this pull request Jul 22, 2023
@keith
Copy link
Member Author

keith commented Jul 22, 2023

we might have to test with swiftlang/swift-driver#1402 to be 100% sure this is working

@keith
Copy link
Member Author

keith commented Jul 22, 2023

Please test with following pull request:
swiftlang/swift-driver#1402

@swift-ci Please test Linux platform

@keith keith force-pushed the ks/mark-start-stop-sections-as-shf_gnu_retain branch from 3821f7c to c09b07b Compare July 22, 2023 20:44
@keith
Copy link
Member Author

keith commented Jul 22, 2023

Hrm our jobs failed but I don't think it's related to this, but the issues from this in the past were subtle so it could be

@keith
Copy link
Member Author

keith commented Jul 22, 2023

swiftlang/swift-driver#1402

@swift-ci Please test Linux platform

@keith
Copy link
Member Author

keith commented Jul 22, 2023

I believe this is the relevant part of the log:

---
4.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Swift)
5.	While running pass #38079 SILFunctionTransform "ComputeSideEffects" on SILFunction "@$sSNsSxRzSZ6StrideRpzrlE10startIndexSNsSxRzSZABRQrlE0C0Oyx_Gvg".
 for getter for startIndex (at /home/build-user/swift/stdlib/public/core/ClosedRange.swift:209:14)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/home/build-user/build/buildbot_linux/swift-linux-x86_64/bootstrapping1/bin/swift-frontend[0x6da26d3]

@finagolfin
Copy link
Member

This is failing when bootstrapping: my guess is that something about this attribute is making the bootstrap1 compiler crash, as the bootstrap0 compiler works fine on the linux CI. The difference is that the bootstrap1 compiler links against the Swift stdlib that you're modifying here, while the bootstrap0 compiler doesn't.

Is this working for you locally?

@keith
Copy link
Member Author

keith commented Jul 23, 2023

It works for me locally but I'm not bootstrapping, I'll try that flow!

@keith
Copy link
Member Author

keith commented Jul 24, 2023

Doesn't fail for me with this command either:

./swift/utils/build-script --release-debuginfo --skip-early-swift-driver --skip-early-swiftsyntax --sccache --build-subdir raw-cmd --extra-cmake-options="-DLLVM_USE_LINKER=/home/ksmiley/.bin/ld.lld,-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=NO,-DSWIFT_USE_LINKER=lld"

@keith
Copy link
Member Author

keith commented Jul 24, 2023

trying with the command from CI:

./swift/utils/build-script --assertions --swift-enable-ast-verifier=0 --no-swift-stdlib-assertions '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;static-mirror-lib;toolchain-tools;license;sourcekit-inproc' '--llvm-install-components=llvm-ar;llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file' --llbuild --swiftpm --swift-driver --xctest --libicu --swiftdocc --build-ninja --install-llvm --install-swift --install-lldb --install-llbuild --install-swiftpm --install-swift-driver --install-swiftsyntax --install-xctest --install-libicu --install-prefix=/usr --install-sourcekit-lsp --install-swiftformat --install-swiftdocc --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --test-installable-package --toolchain-benchmarks --install-destdir=/home/build-user/swift-nightly-install --installable-package=/home/build-user/PR-ubuntu2004.tar.gz --relocate-xdg-cache-home-under-build-subdir --skip-early-swift-driver --skip-early-swiftsyntax --build-subdir=buildbot_linux --lldb --release --test --validation-test --long-test --stress-test --test-optimized --foundation --libdispatch --indexstore-db --sourcekit-lsp --swiftdocc '--lit-args=-v --time-tests' --lldb-test-swift-only --install-foundation --install-libdispatch --reconfigure

@finagolfin
Copy link
Member

Does adding -DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=NO disable bootstrapping, because the bootstrap relies on C++ Interop? That may be why that command works for you.

@keith
Copy link
Member Author

keith commented Jul 24, 2023

🙃 I can try without that, I added that to avoid a different issue originally:

<unknown>:0: warning: the '-enable-experimental-cxx-interop' flag is deprecated; please pass '-cxx-interoperability-mode=' instead
<unknown>:0: note: Swift will maintain source compatibility for imported APIs based on the selected compatibility mode, so updating the Swift compiler will not change how APIs are imported
=== /home/ksmiley/dev/oss-swift/swift/stdlib/public/Cxx/std/std.swift:13:19 ===
12 |
13 | @_exported import CxxStdlib // Clang module
   |                   ^ error: underlying Objective-C module 'CxxStdlib' not found
14 | @_exported import Cxx // Swift module

@keith
Copy link
Member Author

keith commented Jul 24, 2023

I don't think it disables bootstrapping because I see this in the output:

-- Building host Swift tools for LINUX x86_64
--   Build type:     RelWithDebInfo
--   Assertions:     TRUE
--   LTO:
--   Bootstrapping:  BOOTSTRAPPING

but I will try without it anyways

@finagolfin
Copy link
Member

error: underlying Objective-C module 'CxxStdlib' not found

This should be fixed by #65534, if you update to latest trunk or apply that patch to your checkout.

@finagolfin
Copy link
Member

I don't think it disables bootstrapping

You can check by running something like this on your build:

> readelf -d build/Ninja-Release/swift-linux-x86_64/bootstrapping1/bin/swift-frontend | grep libswiftCore

@keith
Copy link
Member Author

keith commented Jul 24, 2023

Locally this one still passes (even without that patch):

./swift/utils/build-script --release-debuginfo --skip-early-swift-driver --skip-early-swiftsyntax --sccache --build-subdir raw-cmd2 --extra-cmake-options="-DLLVM_USE_LINKER=/home/ksmiley/.bin/ld.lld,-DSWIFT_USE_LINKER=lld"

The CI command is still running

@keith
Copy link
Member Author

keith commented Jul 24, 2023

You can check by running something like this on your build:

I'm not sure exactly what you see as the difference here but I see:

% readelf -d build/raw-cmd2/swift-linux-x86_64/bootstrapping1/bin/swift-frontend| grep -i core
 0x0000000000000001 (NEEDED)             Shared library: [libswiftCore.so]

In this case

@keith
Copy link
Member Author

keith commented Jul 24, 2023

Interestingly the CI command fails with:

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol stderr; recompile with -fPIC
>>> defined in /lib/x86_64-linux-gnu/libc.so.6
>>> referenced by stdio2.h:100 (/usr/include/x86_64-linux-gnu/bits/stdio2.h:100)
>>>               object.o:(_PyObject_AssertFailed) in archive /home/ksmiley/.pyenv/versions/3.10.4/lib/libpython3.10.a

But maybe that's because i'm using not the system python in this case so I'll try to remove that and build again

@finagolfin
Copy link
Member

Are you doing clean rebuilds locally? The final thing to try would be to remove your --extra-cmake-options changing the linker to lld, as the linux CI uses gold.

@keith
Copy link
Member Author

keith commented Jul 24, 2023

Yea I guess the reason I'm using lld is because the bug only surfaces with that, so if it does end up passing with gold (after that crash is resolved) I'm not sure we'd be validating the change actually works

@keith
Copy link
Member Author

keith commented Jul 24, 2023

In this case my builds were clean yes (I passed a new build-subdir) (although I am using sccache)

@finagolfin
Copy link
Member

I guess the reason I'm using lld is because the bug only surfaces with that, so if it does end up passing with gold (after that crash is resolved) I'm not sure we'd be validating the change actually works

The problem is that this pull is currently crashing the linux CI with gold, so you'll have to fix that first to ever have a hope of getting this in.

@kateinoigakukun
Copy link
Member

Please test with following pull request:
swiftlang/swift-driver#1402

@swift-ci Please test Linux platform

@finagolfin
Copy link
Member

Anything change recently that should make this work?

@kateinoigakukun
Copy link
Member

I don't know but I'm going to work on a similar issue for wasm, so I'd like to know the latest status of the fix.

@keith
Copy link
Member Author

keith commented Jan 30, 2024

I believe the current issue is that there is some other place not covered by this change where these sections are created as well, and we need to flip this option in that place as well. That's just an assumption but the current result is ld.gold crashes I assume because of that mismatch

kateinoigakukun added a commit to kateinoigakukun/swift that referenced this pull request Feb 1, 2024
@keith
Copy link
Member Author

keith commented Feb 16, 2024

@etcwilde you might be interested in this, I feel like it's close but haven't had the time to dig into it more

@kateinoigakukun
Copy link
Member

Just FYI: I'm doing some experiments on #71373

@keith
Copy link
Member Author

keith commented Mar 4, 2024

#72061

@keith keith closed this Mar 4, 2024
@keith keith deleted the ks/mark-start-stop-sections-as-shf_gnu_retain branch March 4, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants