CMake issueshttps://gitlab.kitware.com/cmake/cmake/-/issues2023-06-08T11:03:51-04:00https://gitlab.kitware.com/cmake/cmake/-/issues/24984Ninja/ASM/Apple: Fat library fails to rebuild after assembly source file is u...2023-06-08T11:03:51-04:00Thomas A.Ninja/ASM/Apple: Fat library fails to rebuild after assembly source file is updated<!--
This issue tracker is for CMake upstream development:
* If you are having trouble building a specific third-party project
that uses CMake, ask for help in that project's forums first.
* If you have a coding or usage question, pl...<!--
This issue tracker is for CMake upstream development:
* If you are having trouble building a specific third-party project
that uses CMake, ask for help in that project's forums first.
* If you have a coding or usage question, please ask for help
on the CMake discourse forums: https://discourse.cmake.org/
-->
# Issue
When ninja tries to build a fat library that contains an assembly source, it will fail to build on a consecutive run when the assembly source has been updated.
```
[2/2] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar cr libdylib1_10_5.a CMakeFiles/dylib1_10_5.dir/dyld_glue.S.o && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib libdylib1_10_5.a && :
FAILED: libdylib1_10_5.a
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar cr libdylib1_10_5.a CMakeFiles/dylib1_10_5.dir/dyld_glue.S.o && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib libdylib1_10_5.a && :
ar: libdylib1_10_5.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: libdylib1_10_5.a: Inappropriate file type or format
ninja: build stopped: subcommand failed.
```
From my testing, the following two conditions need to be met for this bug to occur:
* the object built must be universal binary (ex: `set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")`).
* The source file needs to be an assembly file.
This issue does not occur when using `make`. This has been tested on macOS (this issue can also happen on Linux when cross-building macOS executables).
# How to reproduce
1. Clone `https://github.com/apple-oss-distributions/Csu.git`. Checkout `Csu-88`.
2. Add the following `CMakeLists.txt` file & rename `dyld_glue.s` to `dyld_glue.S`:
```cmake
cmake_minimum_required(VERSION 3.24.2)
project(csu)
enable_language(ASM)
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
ADD_LIBRARY(dylib1_10_5 STATIC dyld_glue.S)
target_compile_options(dylib1_10_5
PRIVATE
-r
-Os
-mmacosx-version-min=10.5
-nostdlib
-keep_private_externs
-DCFM_GLUE
)
```
3. Create a `build` folder and build the library as you normally would:
```
mkdir build
cd build
cmake .. -GNinja
ninja -v
```
4. Use `touch` to simulate file being updated and do another `ninja` build:
```
touch ../dyld_glue.S
ninja -v
```
5. You should get a build failure.
# Version details
```
% sw_vers
ProductName: macOS
ProductVersion: 13.4
BuildVersion: 22F66
% cmake --version
cmake version 3.26.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
```https://gitlab.kitware.com/cmake/cmake/-/issues/24317ASM_MARMASM: Support for compile definitions and options2024-03-10T12:16:50-04:00Brad KingASM_MARMASM: Support for compile definitions and options!7793 added support for the `ASM_MARMASM` language, for #23999.
However, there are some features missing:
* `target_compile_definitions`
* With Ninja, ~~the definitions are added with `-D`~~ (EDIT: Removed by !9326), which is not ...!7793 added support for the `ASM_MARMASM` language, for #23999.
However, there are some features missing:
* `target_compile_definitions`
* With Ninja, ~~the definitions are added with `-D`~~ (EDIT: Removed by !9326), which is not a valid flag for the `armasm64` tool.
* With Visual Studio, the definitions are put in the `.vcxproj` file, but they do not appear on the `armasm64` command line.
* `target_compile_options`
* With Ninja, the compile options are added.
* ~~With Visual Studio, the compile options are not placed in the `.vcxproj` file, similar to #24289 for MASM.~~ EDIT: This was fixed by !8125.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/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/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/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/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/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/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/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/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/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/16546VS: Cannot compile two `.asm` files with the same name2017-10-13T13:17:55-04:00Egor PuginVS: Cannot compile two `.asm` files with the same nameHi,
There's some mess with generated Object File property in VS solution for .asm files. The repro is in archive.
Unpack, then run:
```
mkdir win32 && cd win32 && cmake .. && cmake --build .
```
I see:
```
CustomBuild:
B...Hi,
There's some mess with generated Object File property in VS solution for .asm files. The repro is in archive.
Unpack, then run:
```
mkdir win32 && cd win32 && cmake .. && cmake --build .
```
I see:
```
CustomBuild:
Building Custom Rule H:/Temp/101/CMakeLists.txt
CMake does not need to re-run because H:\Temp\101\win32\CMakeFiles\generate.stamp is up-to-date.
_MASM:
Assembling H:\Temp\101\1.asm...
cmd.exe /C "C:\Users\egor\AppData\Local\Temp\tmp5dd0185685ca4204854801f7d64c5345.cmd"
ml.exe /c /nologo /Zi /Fo"x.dir\Debug\/1.obj" /D"_M_X86" /D"CMAKE_INTDIR="Debug"" /W3 /errorReport:prompt /safeseh /TaH:\Temp\101\1.asm
_MASM:
Assembling H:\Temp\101\b3e3654a.dir\1.asm...
cmd.exe /C "C:\Users\egor\AppData\Local\Temp\tmp9593c5d4a3f34d2baea0f10f674db120.cmd"
ml.exe /c /nologo /Zi /Fo"x.dir\Debug\/b3e3654a.dir/1.obj" /D"_M_X86" /D"CMAKE_INTDIR="Debug"" /W3 /errorReport:prompt /safeseh /TaH:\Temp\101\b3
e3654a.dir\1.asm
H:\Temp\101\b3e3654a.dir\1.asm(1): fatal error A1000: cannot open file : x.dir\Debug\/b3e365a. [H:\Temp\101\win32\x.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"
x.dir\Debug\/b3e3654a.dir/1.obj" /D"_M_X86" /D"CMAKE_INTDIR="Debug"" /W3 /errorReport:prompt /safeseh /TaH:\Temp\101\b3e3654a.dir\1.asm" exited wit
h code 1. [H:\Temp\101\win32\x.vcxproj]
Done Building Project "H:\Temp\101\win32\x.vcxproj" (default targets) -- FAILED.
```
`/Fo` option for the second file (under tricky dir) is completely broken! `/Fo"x.dir\Debug\/b3e3654a.dir/1.obj"`
```
H:\Temp\101\b3e3654a.dir\1.asm(1): fatal error A1000: cannot open file : x.dir\Debug\/b3e365a.
```
[asm_repro.zip](/uploads/5ea1b29b6e4912426e3370b1e4470dab/asm_repro.zip)https://gitlab.kitware.com/cmake/cmake/-/issues/15974Some cmake variables not set for gas assembler2017-10-13T13:17:56-04:00Kitware RobotSome cmake variables not set for gas assemblerThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15974). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15974). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/15973ASM-ATT: cannot set assembler using environment variable2017-10-13T13:17:56-04:00Kitware RobotASM-ATT: cannot set assembler using environment variableThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15973). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15973). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/15819CMake / Assembler header .ah file is not visibile2018-04-28T09:16:20-04:00Kitware RobotCMake / Assembler header .ah file is not visibileThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15819). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15819). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/15818The variable CMAKE_ASM_OUTPUT_EXTENSION is ignored when creating a compiled file2018-04-28T09:16:20-04:00Kitware RobotThe variable CMAKE_ASM_OUTPUT_EXTENSION is ignored when creating a compiled fileThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15818). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15818). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/15617When assembler is enabled TI Compiler might end up with wrong archiver2017-10-13T13:17:56-04:00Kitware RobotWhen assembler is enabled TI Compiler might end up with wrong archiverThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15617). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15617). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/15538set_property(SOURCE ) not working for MASM assembly files within Visual Studi...2017-10-13T13:17:56-04:00Kitware Robotset_property(SOURCE ) not working for MASM assembly files within Visual Studio 2014 generatorThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15538). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=15538). Further discussion may take place here.https://gitlab.kitware.com/cmake/cmake/-/issues/14711CMAKE_ASM_MASM_FLAGS and CMAKE_ASM_MASM_FLAGS_xx have no effect2017-10-13T13:17:57-04:00Kitware RobotCMAKE_ASM_MASM_FLAGS and CMAKE_ASM_MASM_FLAGS_xx have no effectThis issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=14711). Further discussion may take place here.This issue was created automatically from an original [Mantis Issue](https://cmake.org/Bug/view.php?id=14711). Further discussion may take place here.