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

ld: unknown option: --start-group #1058

Open
ryandesign opened this issue Apr 12, 2024 · 0 comments
Open

ld: unknown option: --start-group #1058

ryandesign opened this issue Apr 12, 2024 · 0 comments

Comments

@ryandesign
Copy link

draco 1.5.7 fails to link on macOS when using an llvm.org release of clang (as opposed to an Apple release of clang from Xcode or its command line tools). The error is:

ld: unknown option: --start-group

The cause is this code:

if(CMAKE_CXX_COMPILER_ID MATCHES "^Clang|^GNU")
# Third party dependencies can introduce dependencies on system and test
# libraries. Since the target created here is an executable, and CMake
# does not provide a method of controlling order of link dependencies,
# wrap all of the dependencies of this target in start/end group flags to
# ensure that dependencies of third party targets can be resolved when
# those dependencies happen to be resolved by dependencies of the current
# target.
# TODO(tomfinegan): For portability use LINK_GROUP with RESCAN instead of
# directly (ab)using compiler/linker specific flags once CMake v3.24 is in
# wider use. See:
# https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:LINK_GROUP
list(INSERT exe_LIB_DEPS 0 -Wl,--start-group)
list(APPEND exe_LIB_DEPS -Wl,--end-group)
endif()

Apple clang identifies itself with the CMake compiler ID AppleClang (assuming CMP0025 is set to NEW which in my case it is) and llvm.org clang identifies itself as just Clang. This code, therefore, is checking if the compiler is llvm.org clang (or GCC) and if so it is adding the linker flags --start-group and --end-group which the macOS linker does not understand. You are presuming that using a non-Apple build of clang (or using GCC) means compiling on a non-Apple operating system, which is not a valid assumption.

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