Skip to content

[BUG] the CMake toolchain file's linker flags don't play well with other languages #2264

Open

Description

@finagolfin

Description

There was a regression with CMake 3.30 in how linker flags were passed to non-C/C++ and Windows compilers that broke their builds, which we've been working around for awhile now. It would be good to fix the NDK toolchain file instead to replace -Wl, additions with LINKER:, as detailed by @etcwilde here.

I am using a supported NDK

  • I have checked and the NDK I'm using is currently supported

Affected versions

r27, r28, r29, r30

Activity

  1. Steelskin commented on Nov 5, 2026

    @Steelskin

    FYI, the LINKER: syntax in *_LINKER_FLAGS is only supported with CMP0181 (introduced in CMake 4.0). However, CMP0181 can only be queried from toolchain files and try_compile() test projects starting with CMake 4.5+.

    I would suggest fixing this by checking if CMAKE_VERSION is at least 4.5, then querying CMP0181 status and reverting to -Xlinker syntax otherwise, rather than -Wl, syntax since it is more portable for languages like Swift.

    As an aside, the NDK still sets -Qunused-arguments, which is a clang linker driver flag, not a linker flag. I would suggest either removing it if it is no longer required, or adding it to _ANDROID_NDK_INIT_CFLAGS instead.

    I filed this bug with CMake a while ago with more details for features missing from CMake or the NDK for Swift support on Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions