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

[build][cmake] Fix cmake with custom assembler #3382

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

terrelln
Copy link
Contributor

Fixes cmake build when the C compiler isn't used as the assembler. We need to explicitly set the flag -x assembler-with-cpp to enable the preprocessor.

Fixes #3193.

@afbjorklund
Copy link

I think the -x flags is ignored by as, and it is still sending the rest of the cc flags (like before).

Fatal error: bad defsym; format is --defsym name=value

The needed fix is to make cmake use CMAKE_C_COMPILER instead of CMAKE_ASM_COMPILER

Since it is currently passing all the configured C flags, then it needs to be sent to a C compiler ?

@afbjorklund
Copy link

afbjorklund commented Dec 20, 2022

The default configuration when you run cmake, is to set the ASM compiler to "gcc"

But in Buildroot config, they explicitly define the ASM (cross) compiler to be "as"

-DCMAKE_ASM_COMPILER="/usr/bin/as" -DCMAKE_C_COMPILER="/usr/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/bin/g++"

Which "makes sense", I suppose, but breaks the assumption that .S files are handled by cc

@terrelln terrelln force-pushed the issue-3193 branch 2 times, most recently from 02a5163 to d1dd8fc Compare December 20, 2022 19:03
@terrelln
Copy link
Contributor Author

Good point, I had only tested on my Mac. This now passes on both my Mac and Linux machines with -DCMAKE_ASM_COMPILER=as.

We just set the source language to C. While this isn't ideal, it looks like CMake is preserving this behavior for backwards compatibility.

Tell CMake to explicitly compile our assembly as C code, because we
require it is compiled by a C compiler, and it is only enabled for
clang/gcc.

Fixes facebook#3193.
@terrelln terrelln merged commit 651a381 into facebook:dev Dec 20, 2022
@rkitover
Copy link

I can confirm that this works now on my Gentoo system as well, thank you!

@Cyan4973 Cyan4973 mentioned this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot build with cmake -DCMAKE_ASM_COMPILER=as or llvm-as
5 participants