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

build: check lld version for linker scripts #31282

Closed
wants to merge 1 commit into from

Conversation

devsnek
Copy link
Member

@devsnek devsnek commented Jan 9, 2020

Fixes #31249

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
    /node/blob/master/doc/guides/contributing/pull-requests.md#commit-message-guidelines)

@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Jan 9, 2020
@devsnek devsnek requested a review from bnoordhuis January 9, 2020 17:30
@nodejs-github-bot
Copy link
Collaborator

@@ -747,6 +747,21 @@ def get_llvm_version(cc):
return get_version_helper(
cc, r"(^(?:FreeBSD )?clang version|based on LLVM) ([0-9]+\.[0-9]+)")

def get_lld_version(cc):
try:
proc = subprocess.Popen(shlex.split(cc) + ['-Xlinker', '-v'],
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look correct to me although the CI seems to accept it... Here is what happens when I run cc -Xlinker -v on my MBA:

$ cc -v
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ cc -Xlinker -v
@(#)PROGRAM:ld  PROJECT:ld64-450.3
BUILD 18:16:53 Apr  5 2019
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
        /usr/local/lib
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

$ echo $?
1

proc.communicate() returns a (None, None) tuple.

A proper invocation needs to:

  1. ensure that the linker is actually invoked (e.g. -c won't do)
  2. trick cc into thinking the linker actually did something

The python equivalent of echo 'int main(){}' | cc -Xlinker -v -P -x c -o /dev/null - would do it but it's perhaps not very elegant...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. --version seems to work on ld.lld, lld-link, and wasm-ld, but not ld64.lld. I'm not really sure what to do.

@devsnek devsnek closed this Jan 11, 2020
@devsnek devsnek deleted the fix-build-lld branch January 11, 2020 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to build master, linking fails
5 participants