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

Incorrect usage of CMAKE_C_SIMULATE_ID #9896

Open
thrimbor opened this issue Jan 11, 2025 · 0 comments
Open

Incorrect usage of CMAKE_C_SIMULATE_ID #9896

thrimbor opened this issue Jan 11, 2025 · 0 comments

Comments

@thrimbor
Copy link

Summary

CMakeLists.txt currently uses CMAKE_C_SIMULATE_ID (if set) to decide which cli parameter syntax to use. This is not correct usage of this variable, as its value specifies ABI compatibility, not frontend cli syntax (docs here).
Instead, CMAKE_C_COMPILER_FRONTEND_VARIANT should be used for that instead (docs here).

This issue will rarely cause problems as most people using clang for the MSVC ABI will probably use clang-cl, but I did hit it while updating the nxdk-based Xbox port of Mbed-TLS, where we use clang as our compiler, but with GNU-style cli while targeting MSVC ABI.

The issue was introduced by #8389 / #9273

System information

Mbed TLS version: 3.6.2 and development branch
Operating system and version: Arch Linux host, nxdk target
Compiler and options: clang 18.1.8 from Arch repos with nxdk-cc wrapper script
Additional environment information:

Expected behavior

The library compiles, using GNU-style parameters for the compiler

Actual behavior

Building the library aborts because MSVC-style parameters were passed to clang

clang: error: no such file or directory: '/W3'
clang: error: no such file or directory: '/utf-8'

Steps to reproduce

I don't expect anyone to actually reproduce this because actually triggering the error is very much a niche thing, but these are the steps:

  • Clone https://github.com/XboxDev/nxdk.git and install the prerequisites
  • Run bin/activate in the nxdk repo
  • Build nxdk itself with make NXDK_ONLY=y
  • Configure Mbed-TLS with nxdk-cmake -DCMAKE_BUILD_TYPE=Release ../ -GNinja -DMBEDTLS_FATAL_WARNINGS=OFF -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF
  • Try building with ninja

Additional information

For reference, these are the variable values for nxdk:

CMAKE_C_SIMULATE_ID: MSVC
CMAKE_C_COMPILER_ID: Clang
CMAKE_C_COMPILER_FRONTEND_VARIANT: GNU
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