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

clang: error: unsupported option '-static-libgcc' on MacOS #1554

Closed
2 tasks done
mapleFU opened this issue Jul 6, 2023 · 3 comments
Closed
2 tasks done

clang: error: unsupported option '-static-libgcc' on MacOS #1554

mapleFU opened this issue Jul 6, 2023 · 3 comments
Assignees
Labels
enhancement type enhancement

Comments

@mapleFU
Copy link
Member

mapleFU commented Jul 6, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Motivation

On MacOS clang-13, it doesn't support -static-libgcc. So the code below might get:

clang: error: unsupported option '-static-libgcc'

Is this expected?

Solution

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+    if (NOT APPLE)
+       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+    endif()

    if(ENABLE_STATIC_LIBSTDCXX)
        try_compile(FOUND_STATIC_LIBSTDCXX ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/checks/static_libstdcxx.cc
            LINK_OPTIONS -static-libstdc++ CXX_STANDARD 11)

        if(NOT FOUND_STATIC_LIBSTDCXX)
            message(FATAL_ERROR "cannot find static library of libstdc++, please add ENABLE_STATIC_LIBSTDCXX=OFF to disable")
        endif()

        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
    endif()
endif()

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@mapleFU mapleFU added the enhancement type enhancement label Jul 6, 2023
@PragmaTwice
Copy link
Member

Looks good to me.

@enjoy-binbin
Copy link
Member

It was fixed in #1555

@mapleFU
Copy link
Member Author

mapleFU commented Jul 6, 2023

Too tired today that I forgot to close it, thanks!

@mapleFU mapleFU closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement type enhancement
Projects
None yet
Development

No branches or pull requests

3 participants