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

Non-existent Directory in Linker Path with rules_swift_package_manager #1150

Open
bc-lee opened this issue Jul 7, 2024 · 0 comments
Open

Comments

@bc-lee
Copy link

bc-lee commented Jul 7, 2024

I'm encountering an issue while using rules_swift_package_manager to import third-party Swift package dependencies into my project. The linker path includes a non-existent directory, -LNone.

While this currently doesn't cause linker errors, it's concerning to have a non-existent path in the linker configuration. Additionally, None is a reserved keyword in both Python and Starlark(Bazel's build language), which could potentially lead to confusion.

I made a demo repository that demonstrates three different build methods:

  1. SPM: Uses swift run for building.
  2. Bazel with rules_swift_package_manager: Use CC=clang bazel build //Sources:test-bazel-swift-atomics
  3. Bazel with Manual BUILD File: Use CC=clang bazel build //Sources:test-bazel-swift-atomics-alt

For easier reproduction, a GitHub action running the build command has been included. You can access the build log here: link to build log

The following snippet displays the linker command generated by Bazel with rules_swift_package_manager:

"/home/runner/work/test-bazel-swift-atomics/test-bazel-swift-atomics/swift/usr/bin/ld.lld" -pie --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bazel-out/k8-fastbuild/bin/Sources/test-bazel-swift-atomics /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/14/crtbeginS.o -LNone -L/home/runner/work/test-bazel-swift-atomics/test-bazel-swift-atomics/swift/usr/lib/swift/linux -L/usr/lib/gcc/x86_64-linux-gnu/14 -L/usr/lib/gcc/x86_64-linux-gnu/14/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/lib -L/usr/lib -S -no-as-needed -z relro -z now bazel-out/k8-fastbuild/bin/Sources/test-bazel-swift-atomics_objs/main.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Conformances/OptionalRawRepresentable.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Conformances/RawRepresentable.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Conformances/autogenerated/AtomicBool.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Conformances/autogenerated/IntegerConformances.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Conformances/autogenerated/PointerConformances.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Primitives/autogenerated/Primitives.native.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Primitives/autogenerated/Primitives.shims.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Protocols/AtomicInteger.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Protocols/AtomicOptionalWrappable.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Protocols/AtomicReference.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Protocols/AtomicStorage.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Protocols/AtomicValue.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/AtomicMemoryOrderings.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/DoubleWord.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/ManagedAtomic.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/ManagedAtomicLazyReference.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/UnsafeAtomic.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/UnsafeAtomicLazyReference.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Types/autogenerated/IntegerOperations.swift.o bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.rspm_objs/Sources/Atomics/Unmanaged__SPACE__extensions.swift.o --start-lib bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/_objs/_AtomicsShims.rspm/_AtomicsShims.pic.o --end-lib bazel-out/k8-fastbuild/bin/external/rules_swift_package_manager~~swift_deps~swiftpkg_swift_atomics/Atomics.modulewrap.o -lswiftSwiftOnoneSupport -lswiftCore -lswift_Concurrency -lswift_StringProcessing -lswift_RegexParser -z nostart-stop-gc bazel-out/k8-fastbuild/bin/Sources/Sources_test_bazel_swift_atomics.modulewrap.o -lswiftSwiftOnoneSupport -lswiftCore -lswift_Concurrency -lswift_StringProcessing -lswift_RegexParser -lBlocksRuntime -ldispatch -lswiftDispatch -z nostart-stop-gc -rpath /home/runner/work/test-bazel-swift-atomics/test-bazel-swift-atomics/swift/usr/lib/swift/linux -lm -lstdc++ -lrt -ldl /home/runner/work/test-bazel-swift-atomics/test-bazel-swift-atomics/swift/usr/lib/swift/linux/x86_64/swiftrt.o --push-state -as-needed -lstdc++ --pop-state --push-state -as-needed -lm --pop-state -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc/x86_64-linux-gnu/14/crtendS.o /lib/x86_64-linux-gnu/crtn.o

As you can see, the -LNone flag is present in the linker path.

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

No branches or pull requests

1 participant