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

Resolve which type of linker is used and assign proper linking flags #751

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

petricm
Copy link

@petricm petricm commented Nov 19, 2020

resolves #733
BEGINRELEASENOTES

  • Resolve which type of linker is used and assign proper linking flags

ENDRELEASENOTES

The approach is based calling compiler -Wl,--version which gives:

  • for normal GNU ld
    $ g++ -Wl,--version
    collect2 version 9.2.0
    GNU ld (GNU Binutils) 2.30
    Copyright (C) 2018 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later version.
    This program has absolutely no warranty.
    
  • for GNU gold
    $ g++ -fuse-ld=gold -Wl,--version
    collect2 version 9.2.0
    GNU gold (GNU Binutils 2.30) 1.15
    Copyright (C) 2018 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later version.
    This program has absolutely no warranty.
    
  • for LLD
    $ g++ -fuse-ld=lld -Wl,--version
    collect2 version 9.2.0
    LLD 4.0.1 (tags/RELEASE_401/final 306736) (compatible with GNU linkers)
    
  • for macOS
    $ clang++ -Wl,-v       
    @(#)PROGRAM:ld  PROJECT:ld64-609
    BUILD 18:16:50 Sep 24 2020
    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/MacOSX.sdk/usr/lib
    Framework search paths:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.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)
    

ld, gold and lld all accept the flag --no-undefined the only case where -undefined,error needs to be used is the macOS linker

@petricm petricm marked this pull request as ready for review November 20, 2020 20:17
@petricm petricm changed the title Check on the fly which linker flags the linker accepts Resolve which type of linker is used and assign proper linking flags Nov 20, 2020
@petricm petricm merged commit 45dc41d into AIDASoft:master Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for GCC on macOS
1 participant