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

[SR-6878] clang-5.0: error: invalid linker name in argument '-fuse-ld=lld' #49427

Closed
bob-wilson opened this issue Jan 31, 2018 · 11 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Comments

@bob-wilson
Copy link

Previous ID SR-6878
Radar rdar://problem/37053028
Original Reporter @bob-wilson
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Driver
Assignee @bob-wilson
Priority Medium

md5: 611b3838863bc284e22e68cac1cfe127

Issue Description:

At least some builds are failing with:

clang-5.0: error: invalid linker name in argument '-fuse-ld=lld'

https://ci.swift.org/job/swift-package-manager-PR-osx-smoke-test/192

(from apple/swift-package-manager#1475

This looks like fallout from Dave Z's change:

commit 9182327
Author: David Zarzycki <dave@znu.io>
Date: Tue Jan 30 07:18:36 2018 -0500

[build system] Prefer LLD if it exists (#14165)

@bob-wilson
Copy link
Author

Dave, can you please take a look at this?

@davezarzycki
Copy link
Collaborator

How strange. -fuse-ld=lld is conditional upon `ld.lld` existing. I'm still digging…

@bob-wilson
Copy link
Author

Maybe Clang has a built-in set of valid linkers and lld isn't one of them? The error doesn't say anything about the linker not existing. We may need to pull in a clang patch or something.

@davezarzycki
Copy link
Collaborator

Hi Bob – At best, I have a speculative "not Apple" fix. What do you want to do? Here it is, for reference:

// diff --git i/cmake/modules/AddSwift.cmake w/cmake/modules/AddSwift.cmake
index 789767f8f1..19bf77720e 100644
--- i/cmake/modules/AddSwift.cmake
+++ w/cmake/modules/AddSwift.cmake
@@ -405,7 +405,8 @@ function(_add_variant_link_flags)

if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
find_program(LDLLD_PATH "ld.lld")
- if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH) OR
+ # Strangely, macOS finds lld and then can't find it when using -fuse-ld=
+ if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
list(APPEND result "-fuse-ld=lld")
diff --git i/cmake/modules/AddSwiftUnittests.cmake w/cmake/modules/AddSwiftUnittests.cmake
index 9caa8f4569..52dcbabab5 100644
--- i/cmake/modules/AddSwiftUnittests.cmake
+++ w/cmake/modules/AddSwiftUnittests.cmake
@@ -48,7 +48,8 @@ function(add_swift_unittest test_dirname)
endif()

find_program(LDLLD_PATH "ld.lld")
- if(SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH)
+ # Strangely, macOS finds lld and then can't find it when using -fuse-ld=
+ if(SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE)
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -fuse-ld=lld")
elseif(SWIFT_ENABLE_GOLD_LINKER AND

@davezarzycki
Copy link
Collaborator

See GitHub PR #14306 if you want the speculative fix.

@davezarzycki
Copy link
Collaborator

Hi @bob-wilson — I've merged #14306. Please let me know if it helps or not.

@davezarzycki
Copy link
Collaborator

Hi Bob – Please close this or assign this back to me if builds at Apple are still grumpy. Thanks!

@bob-wilson
Copy link
Author

Sorry for the delay in looking at this. Clang has this code:

    if (Triple.isOSDarwin())
      LinkerName.append("ld64.");
    else
      LinkerName.append("ld.");

When you specify -fuse-ld=lld on Darwin, Clang will look for ld64.lld. For some context, see https://reviews.llvm.org/D38290.

We could conditionalize the find_program test here to match, but judging from the comments on the patch review, it doesn't sound like lld is really ready for prime time on Darwin. Leaving it disabled for Apple platforms seems like the right thing for now, but I'd like to clarify that code to avoid future confusion.

@davezarzycki
Copy link
Collaborator

Let's just close this because when `lld` on Darwin matures to the point that Swift wants to adopt it on Darwin, then the right thing will happen anyway. We don't need this bug.

@bob-wilson
Copy link
Author

I left it open on purpose to remind me to follow up. I still want to follow up, at least to fix the comment in that change.

@bob-wilson
Copy link
Author

Comment update here: #16407

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project
Projects
None yet
Development

No branches or pull requests

2 participants