CMake issueshttps://gitlab.kitware.com/cmake/cmake/-/issues2018-11-12T08:16:32-05:00https://gitlab.kitware.com/cmake/cmake/-/issues/18575ASM compiler id not found for Clang with CMake 3.13.0-rc32018-11-12T08:16:32-05:00Gregor JasnyASM compiler id not found for Clang with CMake 3.13.0-rc3Hello,
I noticed that CMake 3.13.0-rc3 has broken support for GNU assembly for Android. CMake 3.12.3 works as expected. Testcase:
Content of `CMakeLists.txt`:
```CMake
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(test...Hello,
I noticed that CMake 3.13.0-rc3 has broken support for GNU assembly for Android. CMake 3.12.3 works as expected. Testcase:
Content of `CMakeLists.txt`:
```CMake
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(testcase)
enable_language(ASM)
add_library(foo STATIC foo.S)
```
Content of `foo.S`
```
.arm
```
Configure with: `cmake -GNinja -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=/opt/android-ndk-r16b -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_VERSION=19 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang ..`
Resulting compilation line with CMake 3.12: `/opt/android-ndk-r16b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7-none-linux-androideabi --sysroot=/opt/android-ndk-r16b/sysroot -g -fPIC -MD -MT CMakeFiles/foo.dir/foo.S.o -MF CMakeFiles/foo.dir/foo.S.o.d -o CMakeFiles/foo.dir/foo.S.o -c ../foo.S`
Faulty line with 3.13rc: `/opt/android-ndk-r16b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -o CMakeFiles/foo.dir/foo.S.o -c ../foo.S`
Thanks,
Gregor3.13.0Brad KingBrad Kinghttps://gitlab.kitware.com/cmake/cmake/-/issues/18912Compiling ASM source does not work with Visual Studio compiler, VS project or...2019-02-14T15:58:12-05:00Wil StarkCompiling ASM source does not work with Visual Studio compiler, VS project or NMakeThis code:
```cmake
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(TestAsm C ASM)
file(WRITE ${CMAKE_BINARY_DIR}/test.s "; Test ASM file\n")
file(WRITE ${CMAKE_BINARY_DIR}/main.c "// Main\nint main(int argc, char* argv[])\n...This code:
```cmake
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(TestAsm C ASM)
file(WRITE ${CMAKE_BINARY_DIR}/test.s "; Test ASM file\n")
file(WRITE ${CMAKE_BINARY_DIR}/main.c "// Main\nint main(int argc, char* argv[])\n{}\n")
add_executable(myprog test.s main.c)
```
results in this with the VS10 generator (VS12):
```xml
<ItemGroup>
<None Include="C:\TEMP\test\cmake_multi\VS12\test.s" />
<ClCompile Include="C:\TEMP\test\cmake_multi\VS12\main.c" />
</ItemGroup>
```
The VS project lists test.s as "no action" for compiling, rather than assembling with MASM.
When using NMake (using a VS15 command shell), the build prints out:
```
[ 33%] Building ASM object CMakeFiles/myprog.dir/test.s.obj
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9024 : unrecognized source file type 'C:\TEMP\test\cmake_multi\NMake15\test.s', object file assumed
cl : Command line warning D9027 : source file 'C:\TEMP\test\cmake_multi\NMake15\test.s' ignored
cl : Command line warning D9021 : no action performed
[ 66%] Building C object CMakeFiles/myprog.dir/main.c.obj
main.c
```
It appears to be trying to compile test.s with cl.exe and failing. VS will use ml.exe as the assember, or for WindowsCE (WEC2013) targeting ARM, it will use armasm.exe. So... CMake is not detecting and using these assemblers?
This was using cmake 3.13.0-rc1 on Win10/x64.https://gitlab.kitware.com/cmake/cmake/-/issues/19014Add NASM support in Xcode Generator2019-06-21T12:29:27-04:00Harry MallonAdd NASM support in Xcode GeneratorSpun out from https://gitlab.kitware.com/cmake/cmake/issues/16469#note_531760
Xcode generator does not support using NASM sources correctly (it is possible to work around with custom stuff). Native support would be great.
Specific exam...Spun out from https://gitlab.kitware.com/cmake/cmake/issues/16469#note_531760
Xcode generator does not support using NASM sources correctly (it is possible to work around with custom stuff). Native support would be great.
Specific example is libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turboGregor JasnyGregor Jasnyhttps://gitlab.kitware.com/cmake/cmake/-/issues/19178VS/ASM_MASM: sources not getting compile definitions added via target_compile...2021-04-19T10:03:59-04:00Alastair HolmesVS/ASM_MASM: sources not getting compile definitions added via target_compile_definitions()The source file 'test.asm' doesn't get the compiled with the compile definition 'LANG_IS_MASM' in the following CMake:
```
cmake_minimum_required(VERSION 3.14)
project("problem")
enable_language(ASM_MASM)
add_library(Problem STATIC "te...The source file 'test.asm' doesn't get the compiled with the compile definition 'LANG_IS_MASM' in the following CMake:
```
cmake_minimum_required(VERSION 3.14)
project("problem")
enable_language(ASM_MASM)
add_library(Problem STATIC "test.asm")
target_compile_definitions(Problem PRIVATE "MY_MASM_DEFINITION")
```
Using VS 15 2017 Generator
Also even if set like this: `set(CMAKE_ASM_MASM_FLAGS "/DMY_MASM_DEFINITION" ${CMAKE_ASM_MASM_FLAGS})`. It is still isn't compiled with the definitions, but if I do this instead `set(CMAKE_ASM_MASM_FLAGS "MY_FAKE_FLAG" ${CMAKE_ASM_MASM_FLAGS})`, 'MY_FAKE_FLAG' does get passed to the compiler.
I am also seeing the same problem using `set_target_properties`.
Using `set_target_properties(Problem PROPERTIES COMPILE_DEFINITIONS "MY_MASM_DEFINITION")` to set the compile definition does seem to work.
Edit:
I tried this also with ASM_NASM and the same issue exists.https://gitlab.kitware.com/cmake/cmake/-/issues/19644CMAKE_ASM_ARCHIVE_CREATE, _APPEND and _FINISH are silently ignored2019-08-27T09:23:06-04:00Marc HerbertCMAKE_ASM_ARCHIVE_CREATE, _APPEND and _FINISH are silently ignoredhttps://cmake.org/cmake/help/v3.14/variable/CMAKE_LANG_ARCHIVE_CREATE.html doesn't treat ASM differently from C and C++ and doesn't say CMAKE_ASM_ARCHIVE_CREATE is missing. However defining CMAKE_ASM_ARCHIVE_CREATE and friends is silent...https://cmake.org/cmake/help/v3.14/variable/CMAKE_LANG_ARCHIVE_CREATE.html doesn't treat ASM differently from C and C++ and doesn't say CMAKE_ASM_ARCHIVE_CREATE is missing. However defining CMAKE_ASM_ARCHIVE_CREATE and friends is silently ignored.
Comparing [/usr/share/cmake/Modules/] CMakeASMInformation.cmake with CMakeCInformation.cmake and CMakeCXXInformation.cmake in version 3.14, one can see that CMAKE_ASM_ARCHIVE_CREATE and friends simply don't exist.
Maybe _ASM is different by design and this Works As Intended? In such a case please consider as a missing documentation bug.
Workarounds:
- Add at least one (empty) C file to add_library(): `add_library(a.s b.S ... empty.c)` and use `CMAKE_C_ARCHIVE_CREATE` instead. See tested example at https://github.com/zephyrproject-rtos/zephyr/pull/17632/
- Provide the entire, higher level `CMAKE_ASM_CREATE_STATIC_LIBRARY` function instead. This runs into other issues, see #19474
Test code for quick reproduction:
```cmake
# Test with:
#
# rm -rf build/; cmake -B build && make -C build VERBOSE=1 mylib
cmake_minimum_required(VERSION 3.14)
project(assembly_lib ASM C)
add_library(mylib STATIC hello_main.S)
# Documented at
# https://cmake.org/cmake/help/v3.14/variable/CMAKE_LANG_ARCHIVE_CREATE.html
# but not implemented in Modules/CMakeASMInformation.cmake and silently ignored.
SET(CMAKE_ASM_ARCHIVE_CREATE
"<CMAKE_AR> qc -should_fail_but_ignored <TARGET> <LINK_FLAGS> <OBJECTS>")
# Optional, just in case you want to actually run the code.
# add_executable(myexe something.c) # something.c can be empty too
# target_link_libraries(myexe mylib)
```https://gitlab.kitware.com/cmake/cmake/-/issues/20236MSVC_RUNTIME_LIBRARY Incompatible with ASM_MASM project2020-02-04T10:41:23-05:00Jonny PatonMSVC_RUNTIME_LIBRARY Incompatible with ASM_MASM projectIf a project contains asm code compiled using ASM_MASM along with cpp code, and you enable policy CMP0091 to modify the MSVC runtime library, the following error occurs:
```
MSVC_RUNTIME_LIBRARY value 'MultiThreadedDebugDLL' not known...If a project contains asm code compiled using ASM_MASM along with cpp code, and you enable policy CMP0091 to modify the MSVC runtime library, the following error occurs:
```
MSVC_RUNTIME_LIBRARY value 'MultiThreadedDebugDLL' not known for this
ASM_MASM compiler.
```
Using Visual studio 2019 (16.4.3) and cmake 3.16.0.
Can be reproduced using a simple CMakeLists like so:
```
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0091 NEW)
project(test C CXX ASM_MASM)
add_library(test_lib test.asm test.cpp)
```3.15.7Brad KingBrad Kinghttps://gitlab.kitware.com/cmake/cmake/-/issues/20426ASM: No include dependecies tracking for the source files2020-08-08T14:01:40-04:00Sergey BelyashovASM: No include dependecies tracking for the source filesMy project is written on assembler. There is no C compiler for target architecture. I try to build project by CMake, but have an issue: CMake does not track `.include` and `.incbin` directives (of GNU Assembler) in the sources. GNU Assem...My project is written on assembler. There is no C compiler for target architecture. I try to build project by CMake, but have an issue: CMake does not track `.include` and `.incbin` directives (of GNU Assembler) in the sources. GNU Assembler have support for `-MD <file>` option which generates dependency file. But it is not used by CMake. Moreover, I found ASM.includechache file in the build directory. It contains:
```
#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">])
#IncludeRegexScan: ^.*$
#IncludeRegexComplain: ^$
#IncludeRegexTransform:
/home/user/test.s
```
It is incorrect for assembler.
I try found which module generate this file, but nothing found.
I attach simple test case for the issue. To reproduce:
1. Unpack, configure and build
2. Change test.inc and build again.
Expected: target is rebuilt
Actual: no second build is done.
[test.s](/uploads/81fb53e0de1f91f8cb9162e0b9cb438b/test.s)
[test.inc](/uploads/309915a20eed86d581e50ee89d8fd560/test.inc)
[CMakeLists.txt](/uploads/ebb8511fe0e29384dd0d0630e422595a/CMakeLists.txt)https://gitlab.kitware.com/cmake/cmake/-/issues/20738VS: ASM_MASM not fully implemented by Visual Studio generators2020-05-22T06:28:25-04:00Sam EdgeVS: ASM_MASM not fully implemented by Visual Studio generatorsTrying to compile a `.asm` file against MSVC 9.0. It's an older project that's locked to this toolchain. By design, this particular `.asm` may only be compiled on x64 platforms.
Here is my minimal CMakeLists.txt:
```
cmake_minimum_requi...Trying to compile a `.asm` file against MSVC 9.0. It's an older project that's locked to this toolchain. By design, this particular `.asm` may only be compiled on x64 platforms.
Here is my minimal CMakeLists.txt:
```
cmake_minimum_required(VERSION 3.17)
project(TestMASM)
enable_language(ASM_MASM)
add_library(Common winos_x64.asm)
```
Make phase:
```
mkdir build
cd build
cmake -G "Visual Studio 9 2008" -A x64 ..\source
-- The C compiler identification is MSVC 15.0.21022.8
-- The CXX compiler identification is MSVC 15.0.21022.8
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/ml64.exe
-- Configuring done
-- Generating done
-- Build files have been written to: xxx
```
It has correctly detected the `ml64` ASM compiler. This is also verified in `CMakeCache.txt`:
```
########################
# EXTERNAL cache entries
########################
//ASM_MASM compiler
CMAKE_ASM_MASM_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin/x86_amd64/ml64.exe
```
However, the build phase fails because the `ml.exe` is somehow used in place of `ml64.exe`.
```
Build Log
Build started: Project: Common, Configuration: Release|x64
Command Lines
Creating temporary file "xxx\Release\BAT00000144169512.bat" with contents
[
@echo off
ml.exe /c /nologo /Fo"\Release\winos_x64.obj" /D"CMAKE_INTDIR=\"Release\"" /W3 /Zi /errorReport:prompt /Ta..\source\winos_x64.asm
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Assembling..."
exit 1
:VCEnd
]
Creating command line "xxx\Release\BAT00000144169512.bat"
Output Window
Assembling...
Assembling: ..\source\winos_x64.asm
..\source\Common\winos_x64.asm(4) : error A2013:.MODEL must precede this directive
..\source\Common\winos_x64.asm(6) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(7) : error A2034:must be in segment block : cpuid64
..\source\Common\winos_x64.asm(10) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(11) : error A2008:syntax error : .
..\source\Common\winos_x64.asm(12) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(13) : error A2008:syntax error : .
..\source\Common\winos_x64.asm(14) : error A2008:syntax error : .
..\source\Common\winos_x64.asm(16) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(17) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(18) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(19) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(20) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(21) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(22) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(23) : error A2085:instruction or register not accepted in current CPU mode
..\source\Common\winos_x64.asm(25) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(26) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(28) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(29) : error A2034:must be in segment block
..\source\Common\winos_x64.asm(30) : fatal error A1010:unmatched block nesting : cpuid64
Project : error PRJ0019: A tool returned an error code from "Assembling..."
```
As you can see, the generated .BAT has elected to use `ml.exe` instead of `ml64.exe`. The CMake variables all align with a x64 configuration.
I've isolated problem to MSVC 9.0 (Visual Studio 2008) projects.
I generated solutions for the latest Visual Studio 2019 and it works correctly.https://gitlab.kitware.com/cmake/cmake/-/issues/20771CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES don't work for assembly2020-12-04T09:07:12-05:00David BenjaminCMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES don't work for assemblyThe `CMAKE_OSX_SYSROOT` and `CMAKE_OSX_ARCHITECTURES` settings aren't propagated to assembly files, like they are for C and C++, when building for Apple platforms. Here's a small repro case:
```
$ cat CMakeLists.txt
cmake_minimum_requi...The `CMAKE_OSX_SYSROOT` and `CMAKE_OSX_ARCHITECTURES` settings aren't propagated to assembly files, like they are for C and C++, when building for Apple platforms. Here's a small repro case:
```
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(test)
enable_language(ASM)
if(WORKAROUND)
if(CMAKE_OSX_SYSROOT)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"")
endif()
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}")
endforeach()
endif()
add_executable(test main.c return_zero.S)
$ cat main.c
extern int return_zero(void);
int main() {
return return_zero();
}
$ cat return_zero.S
.text
.align 5
.globl _return_zero
_return_zero:
mov x0, 0
ret
$ cmake -B build1 -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64 && make -C build1
[...]
[ 66%] Building ASM object CMakeFiles/test.dir/return_zero.S.o
[...]/return_zero.S:6:2: error: unknown use of instruction mnemonic without a size suffix
mov x0, 0
^
[...]
$ cmake -B build2 -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64 -DWORKAROUND=1 && make -C build2
[...]
[100%] Built target test
```3.19.0https://gitlab.kitware.com/cmake/cmake/-/issues/20780GNU: Incorrect defines flag for 'as' tool2020-06-02T06:39:52-04:00Brad KingGNU: Incorrect defines flag for 'as' toolOur `RunCMake.BuildDepends` test (in `master`) fails with the Ninja Multi-Config generator when testing with the GNU compiler, which activates the `CMake_TEST_BuildDepends_GNU_AS` part of the test.
See further discussion in https://gitl...Our `RunCMake.BuildDepends` test (in `master`) fails with the Ninja Multi-Config generator when testing with the GNU compiler, which activates the `CMake_TEST_BuildDepends_GNU_AS` part of the test.
See further discussion in https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4832#note_769837.3.18.0Kyle EdwardsKyle Edwardshttps://gitlab.kitware.com/cmake/cmake/-/issues/21376QNX: Preprocessing ASM .S source files2020-11-20T11:48:50-05:00Valentin DinitaQNX: Preprocessing ASM .S source filesStarting with CMake 3.19.0-rc1, a new flag was added to the QCC compiler, "-x c", when the LANGUAGE property for a source file was set to C. Before that, the source file was sent to the right compiler without any additional flag that mig...Starting with CMake 3.19.0-rc1, a new flag was added to the QCC compiler, "-x c", when the LANGUAGE property for a source file was set to C. Before that, the source file was sent to the right compiler without any additional flag that might be caused by the LANGUAGE property.
The .S source files (e.g. in libjpeg-turbo) are C-ASM source code that has to be compiled with the QNX C compiler. The compiler knows how to treat them by extension.
The problem here is the newly added "-x" compile flag. "-x c" tells the compiler to treat the source file as pure C code, and it fails. If we change the LANGUAGE property of the source file to any ASM variant, then the file will be sent to the assembler instead of the QCC compiler, and that fails too.
So, we have C-ASM code, two languages, that has to be compiled with QNX-C compiler (QCC), but not marked as pure-C code with the "-x c". CMake 3.18.0 works just fine.https://gitlab.kitware.com/cmake/cmake/-/issues/21553ASM_NASM: CMake 3.19.1 adds unsupported '-arch x86_64' on macOS2020-12-07T10:28:25-05:00fpliuASM_NASM: CMake 3.19.1 adds unsupported '-arch x86_64' on macOS[https://github.com/libjpeg-turbo/libjpeg-turbo/issues/473](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/473)[https://github.com/libjpeg-turbo/libjpeg-turbo/issues/473](https://github.com/libjpeg-turbo/libjpeg-turbo/issues/473)3.19.2Raul Tambreraul@tambre.eeRaul Tambreraul@tambre.eehttps://gitlab.kitware.com/cmake/cmake/-/issues/21877ASM_NASM: Incorrect command line argument style when using MSVC2021-03-04T12:09:17-05:00Francesco BertolacciniASM_NASM: Incorrect command line argument style when using MSVCOn Windows using MSVC, a simple project such as this one:
```
cmake_minimum_required(VERSION 3.16.0)
project(test VERSION 1.0.0 LANGUAGES C CXX ASM_NASM)
add_library(test STATIC test.asm)
```
fails to link because during the linking ...On Windows using MSVC, a simple project such as this one:
```
cmake_minimum_required(VERSION 3.16.0)
project(test VERSION 1.0.0 LANGUAGES C CXX ASM_NASM)
add_library(test STATIC test.asm)
```
fails to link because during the linking step `link.exe` is called with GNU-style arguments (e.g. `link` complains about not being able to find `cr`)
Additionally, when not specifying `C` or `CXX` languages, building using Ninja fails because no linker is found.https://gitlab.kitware.com/cmake/cmake/-/issues/22341CMake 3.21.0-rc1 broke YASM support2021-06-28T09:19:12-04:00Gregor JasnyCMake 3.21.0-rc1 broke YASM supportThe [nasm_add_deps topic](!5868) introduced generation of GCC-compatible depfiles by the NASM assembler. Unfortunately it closed the door for YASM assembler support because yasm does not support the `-MD` and `-MT` arguments.
The follow...The [nasm_add_deps topic](!5868) introduced generation of GCC-compatible depfiles by the NASM assembler. Unfortunately it closed the door for YASM assembler support because yasm does not support the `-MD` and `-MT` arguments.
The following testcase reproduces the problem:
```cmake
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(testcase NONE)
find_program(NASM_EXECUTABLE yasm)
set(CMAKE_ASM_NASM_COMPILER ${NASM_EXECUTABLE})
enable_language(ASM_NASM)
add_library(foo foo.asm)
```
Building results in an error:
```
ninja -v
[1/2] /opt/homebrew/bin/yasm -MD CMakeFiles/foo.dir/foo.asm.o.d -MT CMakeFiles/foo.dir/foo.asm.o -f macho -o CMakeFiles/foo.dir/foo.asm.o /Users/gregorj/src/cmake-issue-yarn/foo.asm
yasm: warning: can open only one input file, only the last file will be processed
yasm: warning: can open only one input file, only the last file will be processed
CMakeFiles/foo.dir/foo.asm.o: /Users/gregorj/src/cmake-issue-yarn/foo.asm
[2/2] : && /usr/bin/ar cr libfoo.a CMakeFiles/foo.dir/foo.asm.o && /usr/bin/ranlib libfoo.a && :
FAILED: libfoo.a
: && /usr/bin/ar cr libfoo.a CMakeFiles/foo.dir/foo.asm.o && /usr/bin/ranlib libfoo.a && :
ar: CMakeFiles/foo.dir/foo.asm.o: No such file or directory
ninja: build stopped: subcommand failed.
```
Thanks,
Gregor3.21.0Gregor JasnyGregor Jasnyhttps://gitlab.kitware.com/cmake/cmake/-/issues/22817Bug asm in lib on windows with ninja2024-03-06T11:16:26-05:00Andry _Bug asm in lib on windows with ninjaCMAKE_VERSION=3.20.2
ninja --version 1.10.2
I ran into a problem - if I want to create a library based on an asm file for Windows under ninja.
```
add_library(asm_lib file.asm)
```
I get this error
```
FAILED: asm_lib.lib
cmd.exe /C ...CMAKE_VERSION=3.20.2
ninja --version 1.10.2
I ran into a problem - if I want to create a library based on an asm file for Windows under ninja.
```
add_library(asm_lib file.asm)
```
I get this error
```
FAILED: asm_lib.lib
cmd.exe /C "cd . && C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.300\bin\Hostx64\x64\lib.exe cr asm_lib.lib /machine:x64 CMakeFiles\____file.asm.obj && cd ."
Microsoft (R) Library Manager Version 14.29.30040.0
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : fatal error LNK1181: cannot open input file 'cr'
```
as far as I understand, 'cr' is a flag and it is for bin/ar under Linux and not for a lib under Windowshttps://gitlab.kitware.com/cmake/cmake/-/issues/22995CMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN set incorrectly with Clang2021-12-10T09:33:38-05:00Ryan PrichardCMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN set incorrectly with ClangThe `CMAKE_${LANG}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN` flags are set to `--gcc-toolchain=` for current versions of Clang and `-gcc-toolchain ` for versions older than Clang 3.4.0.
Clang doesn't have an program with a GAS-like CLI syntax...The `CMAKE_${LANG}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN` flags are set to `--gcc-toolchain=` for current versions of Clang and `-gcc-toolchain ` for versions older than Clang 3.4.0.
Clang doesn't have an program with a GAS-like CLI syntax and instead reuses the C/C++ compiler driver to assemble files.
When CMake uses Clang to assemble, it sets `CMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN` to `-gcc-toolchain ` regardless of the Clang version. This is a problem because new versions of Clang removed support for `-gcc-toolchain ` in favor of `--gcc-toolchain=`. https://llvm.org/D108494
`CMAKE_ASM_COMPILER_VERSION` is left blank rather than set to match the C/C++ variables.
A test case:
CMakeLists.txt
```
cmake_minimum_required(VERSION 3.21.0)
project(test C CXX ASM)
message(STATUS "CMAKE_ASM_COMPILER_VERSION = ${CMAKE_ASM_COMPILER_VERSION}")
message(STATUS "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "CMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = ${CMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}")
message(STATUS "CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = ${CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}")
message(STATUS "CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = ${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}")
message(STATUS "CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN = ${CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN = ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN = ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
```
Output:
```
$ CC=clang CXX=clang++ cmake -GNinja .
-- The C compiler identification is Clang 11.1.0
-- The CXX compiler identification is Clang 11.1.0
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_ASM_COMPILER_VERSION =
-- CMAKE_C_COMPILER_VERSION = 11.1.0
-- CMAKE_CXX_COMPILER_VERSION = 11.1.0
-- CMAKE_ASM_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = -gcc-toolchain
-- CMAKE_C_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = --gcc-toolchain=
-- CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN = --gcc-toolchain=
-- CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN =
-- CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN =
-- CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN =
-- Configuring done
-- Generating done
-- Build files have been written to: /x/mess/A
```
I'm using CMake from the cmake-3.21.4-1 debian package. I've also noticed it with a local build of CMake 3.22.1.
This issue currently breaks Android's "legacy toolchain file" (as opposed to its newer toolchain file). The legacy file happens to set the `CMAKE_{ASM,C,CXX}_COMPILER_EXTERNAL_TOOLCHAIN` variables, so it's hitting this general CMake+Clang issue. I don't know if this toolchain file needs to set those variables, so maybe removing that setting is an easy fix in future NDK releases.
References:
* https://github.com/android/ndk/issues/1623
* https://android.googlesource.com/platform/ndk/+/refs/tags/ndk-r24-beta1/build/cmake/android-legacy.toolchain.cmake#404
* https://gitlab.kitware.com/cmake/cmake/-/blob/v3.22.1/Modules/Compiler/Clang.cmake#L37-43https://gitlab.kitware.com/cmake/cmake/-/issues/23537MSVC assembler shows "Assembling" messages that should be suppressed2023-02-10T10:49:55-05:00stl@microsoft.comMSVC assembler shows "Assembling" messages that should be suppressedAfter adding an `.asm` file to our repo, the build output is interrupted by "Assembling" messages being printed by MSVC's assembler (`ml64.exe` for x64, `ml.exe` for x86). We're passing `/nologo` to suppress the copyright banner, but tha...After adding an `.asm` file to our repo, the build output is interrupted by "Assembling" messages being printed by MSVC's assembler (`ml64.exe` for x64, `ml.exe` for x86). We're passing `/nologo` to suppress the copyright banner, but that doesn't suppress this message. Example:
```
D:\GitHub\STL>cmake -G Ninja -S . -B out\build\x64
-- The CXX compiler identification is MSVC 19.33.31424.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.33.31424/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.33.31424/bin/Hostx64/x64/ml64.exe
-- Searching for VS clang-format
-- Searching for VS clang-format - found
-- Boost.Math: standalone mode ON
-- Found Python: C:/Users/stl/AppData/Local/Programs/Python/Python310/python.exe (found suitable version "3.10.4", minimum required is "3.9") found components: Interpreter
-- Configuring done
-- Generating done
-- Build files have been written to: D:/GitHub/STL/out/build/x64
D:\GitHub\STL>ninja -C out\build\x64
ninja: Entering directory `out\build\x64'
[108/984] Building ASM_MASM object stl\CMakeFiles\msvcp_implib_objects.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[244/984] Building ASM_MASM object stl\CMakeFiles\msvcpd_implib_objects.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[260/984] Building ASM_MASM object stl\CMakeFiles\libcpmt.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[404/984] Building ASM_MASM object stl\CMakeFiles\libcpmt1.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[541/984] Building ASM_MASM object stl\CMakeFiles\libcpmtd.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[682/984] Building ASM_MASM object stl\CMakeFiles\libcpmtd1.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[828/984] Building ASM_MASM object stl\CMakeFiles\libcpmtd0.dir\src\alias.asm.obj
Assembling: D:\GitHub\STL\stl\src\alias.asm
[984/984] Linking CXX static library out\lib\amd64\libcpmtd0.lib
```
This is similar to https://gitlab.kitware.com/cmake/cmake/-/issues/21422 which was fixed by https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5492 . Could CMake be enhanced to suppress this message when invoking the assembler?https://gitlab.kitware.com/cmake/cmake/-/issues/24078VS/NASM: Same source filename outputs to same OBJ file and directory2022-10-24T14:34:50-04:00Mir DrualgaVS/NASM: Same source filename outputs to same OBJ file and directoryUsing CMake 3.24.2 and NASM 2.15.05. Running Windows 10 Pro 21H2 19044.2130. Attempted to build using "Visual Studio 2019 Community" generator targeting x86.
Target contains C, CXX, and NASM files. C and CXX source files with the same f...Using CMake 3.24.2 and NASM 2.15.05. Running Windows 10 Pro 21H2 19044.2130. Attempted to build using "Visual Studio 2019 Community" generator targeting x86.
Target contains C, CXX, and NASM files. C and CXX source files with the same filename, but different parent directories are able to successfully build into different intermediate object file directories. There is no problem there. However, NASM files that share same filename, but different parent directories do not build into different intermediate object directories, and end up overriding each other. This causes the linker to fail due to missing function definitions.
Example:
```
project
|- foo
|- a.c
|- b.asm
|- bar
|- a.c
|- b.asm
```
In this example, foo/a.c and bar/a.c compile to obj files to different directories. However, foo/b.asm and bar/b.asm compile to obj files in the same directory.https://gitlab.kitware.com/cmake/cmake/-/issues/24134The asm files are not getting compiled when CMAKE_ASM_COMPILER is set to armasm2023-01-10T06:51:24-05:00Randeep KumarThe asm files are not getting compiled when CMAKE_ASM_COMPILER is set to armasmDoes CMake supports armasm compiler? The asm files are not getting compiled when CMAKE_ASM_COMPILER is set to armasm.Does CMake supports armasm compiler? The asm files are not getting compiled when CMAKE_ASM_COMPILER is set to armasm.3.26.0https://gitlab.kitware.com/cmake/cmake/-/issues/24249ASM_MASM: Missing support for MSVC_DEBUG_INFORMATION_FORMAT2022-12-16T08:55:27-05:00stl@microsoft.comASM_MASM: Missing support for MSVC_DEBUG_INFORMATION_FORMATRepros with CMake 3.25.0 shipping in VS 2022 17.5 Preview 2.
In our project ([MSVC's STL](https://github.com/microsoft/STL)), we have ASM_MASM sources. When I tried to increase our minimum required version of CMake, it failed with:
```...Repros with CMake 3.25.0 shipping in VS 2022 17.5 Preview 2.
In our project ([MSVC's STL](https://github.com/microsoft/STL)), we have ASM_MASM sources. When I tried to increase our minimum required version of CMake, it failed with:
```
CMake Error in CMakeLists.txt:
MSVC_DEBUG_INFORMATION_FORMAT value 'ProgramDatabase' not known for this
ASM_MASM compiler.
```
This is related to this new feature mentioned in the [CMake 3.25 release notes](https://cmake.org/cmake/help/latest/release/3.25.html):
> The [`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT`](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html#variable:CMAKE_MSVC_DEBUG_INFORMATION_FORMAT) variable and [`MSVC_DEBUG_INFORMATION_FORMAT`](https://cmake.org/cmake/help/latest/prop_tgt/MSVC_DEBUG_INFORMATION_FORMAT.html#prop_tgt:MSVC_DEBUG_INFORMATION_FORMAT) target property were introduced to select the debug information format for compilers targeting the MSVC ABI. See policy [`CMP0141`](https://cmake.org/cmake/help/latest/policy/CMP0141.html#policy:CMP0141).
As the example below demonstrates, we can work around this by setting the `CMP0141` policy to `OLD`. However, I believe that this workaround should not be necessary, and that this is a bug in CMake - it appears that its internal machinery wasn't taught how to send debug info options to MASM.
While I am not a MASM expert, [MASM documentation](https://learn.microsoft.com/en-us/cpp/assembler/masm/ml-and-ml64-command-line-reference?view=msvc-170) says that `/Zi` "Generates CodeView information in object file.", and comments in MSVC's STL note that (somewhat confusingly) this is equivalent to what `/Z7` does for the `cl.exe` compiler - so `Embedded` in CMake's terminology should be translated to `/Zi` for MASM.
As linked from the release notes, CMake's documentation for [`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT`](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html#variable:CMAKE_MSVC_DEBUG_INFORMATION_FORMAT) says:
> If this variable is not set, the `MSVC_DEBUG_INFORMATION_FORMAT` target property will not be set automatically. If that property is not set, CMake selects a debug information format using the default value `$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>`, if supported by the compiler, and otherwise `$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>`.
If I understand this correctly, because MASM doesn't support `ProgramDatabase`, CMake should fall back to `Embedded` instead of emitting an error that it doesn't know what to do.
```
C:\Temp\REPRO>"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.5.0-pre.2.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Temp\REPRO>cmake --version
cmake version 3.25.0-msvc1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
C:\Temp\REPRO>type CMakeLists.txt
```
```cmake
cmake_minimum_required(VERSION 3.25)
if(DEFINED OVERRIDE_CMP0141)
cmake_policy(SET CMP0141 ${OVERRIDE_CMP0141})
endif()
project(meow_project LANGUAGES CXX ASM_MASM)
set(SOURCES
${CMAKE_CURRENT_LIST_DIR}/meow.cpp
${CMAKE_CURRENT_LIST_DIR}/square.asm
)
add_executable(meow ${SOURCES})
```
```
C:\Temp\REPRO>type meow.cpp
```
```cpp
#include <cstdio>
extern "C" int square(int x);
int main() {
std::printf("\nHello, CMake world!\n");
std::printf("square(7): %d\n", square(7));
}
```
```
C:\Temp\REPRO>type square.asm
PUBLIC square
_TEXT SEGMENT
square PROC
imul ecx, ecx
mov eax, ecx
ret 0
square ENDP
_TEXT ENDS
END
C:\Temp\REPRO>cmake -G Ninja -S . -B out && ninja -C out && out\meow.exe
-- The CXX compiler identification is MSVC 19.35.32124.0
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.35.32124/bin/Hostx64/x64/ml64.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.35.32124/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error in CMakeLists.txt:
MSVC_DEBUG_INFORMATION_FORMAT value 'ProgramDatabase' not known for this
ASM_MASM compiler.
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
C:\Temp\REPRO>cmake -G Ninja -S . -B out -DOVERRIDE_CMP0141=OLD && ninja -C out && out\meow.exe
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Temp/REPRO/out
ninja: Entering directory `out'
[1/3] Building ASM_MASM object CMakeFiles\meow.dir\square.asm.obj
Microsoft (R) Macro Assembler (x64) Version 14.35.32124.0
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: C:\Temp\REPRO\square.asm
[3/3] Linking CXX executable meow.exe
Hello, CMake world!
square(7): 49
```
Note: This seems to be similar to an old issue https://gitlab.kitware.com/cmake/cmake/-/issues/19453 but it is definitely not a duplicate of that issue.3.25.2Brad KingBrad King