Cmake Nasm

The title of this article might seem oddly specific, but this turned out to be less straightforward than I thought itwould (or should) be. I run my Jenkins builds for Visual Studio on a VPS running Windows 2016 server. In the past I washit by a bug where the Visual Studio build tools installer would crash resulting in a corrupted .NET installation insideof the container. More recently a Windows 2016 security update stirred things up even more.

  1. Cmake Assembly File
  2. Cmake Asm Flags
  3. Cmake Nasm Login
  4. Cmake Nasm Flags
  5. Cmake Nasm Login
  6. Cmake Nasm Training

Recently all my Windows docker jobs on Jenkins started failing. Cmake still worked, but anything related to VisualStudio just crashed immediately. This turned out to be the result of a security update that I had received the nightbefore.

I'm learning x64 and I hate make, so I'm trying to get cmake to build binaries with NASM. This is roughly supported by cmake but the documentation is crap. This is what I have working right now by cobbling together stuff from stack overflow and then cutting out everything that doesn't break the build. CMake knows about NASM. NASM is the Netwide Assembler. This is a 16/32/64bit assembler for the Intel platform that works under many operating system and than can output many formats of object code.

Cmake_asm_nasm_compiler

My docker image is based on mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016 and theworkaround described on the page seems straightforward. Since I’m manually installing Visual Studio build tools anyway,I figured I didn’t need the dotnet framework base anymore, and I could base my docker image directly onmcr.microsoft.com/windows/servercore:10.0.14393.3504.

Cmake Assembly File

However if you do this, you will get hit by a much older bug where the Visual Studio build tools installer will stopseemingly without error. However, after that, nothing related to .NET will work properly anymore in the container. Evena simple echo call in Powershell will result in an error complaining about missing .NET 2.0 (which is strange initself).

Cmake Asm Flags

The fix for this is to head over to github and clone themicrosoft/dotnet-framework-docker GIT repository. Share to tv. Then go tothe 4.8runtimewindowsservercore-ltsc2016 subfolder and edit the Dockerfile there to use mcr.microsoft.com/windows/servercore:10.0.14393.3504 instead of the default ltsc2016 version. Build this to alocal image with a name of your choosing. I called mine robindegen/windowsservercore_net48_runtime. Then rebuild theVisual Studio build tools docker image based on this newly created image. The Visual Studio build tools installationshould now succeed and work properly.

Cmake Nasm Login

For those interrested, here is the Dockerfile I use to install Visual Studio 2019 build tools. It also installs CMake,NASM and everything needed to run a Jenkins slave inside of it. This configuration is based on several online examples.I believe that the slave configuration can be simplified; but for the timebeing this works. The Jenkins JNLP portion isbased on an old version of the jenkinsci/docker-jnlp-slave repository.

Cmake Nasm Flags

Here is the slave-launch.ps1 file:

annotate source/cmake/CMakeASM_NASMInformation.cmake @ 12722:cd98d17c690cdraft

Cmake Nasm Login

dateFri, 22 Jan 2021 08:26:58 +0530

Cmake Nasm Training

rev line source
11943
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
1 set(ASM_DIALECT '_NASM')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
2 set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
3
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
4 if(X64)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
5 list(APPEND ASM_FLAGS -DARCH_X86_64=1 -I ${CMAKE_CURRENT_SOURCE_DIR}/./common/x86/)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
6 if(ENABLE_PIC)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
7 list(APPEND ASM_FLAGS -DPIC)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
8 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
9 if(APPLE)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
10 set(ARGS -f macho64 -DPREFIX)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
11 elseif(UNIX AND NOT CYGWIN)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
12 set(ARGS -f elf64)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
13 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
14 set(ARGS -f win64)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
15 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
16 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
17 list(APPEND ASM_FLAGS -DARCH_X86_64=0 -I ${CMAKE_CURRENT_SOURCE_DIR}/./common/x86/)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
18 if(APPLE)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
19 set(ARGS -f macho32 -DPREFIX)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
20 elseif(UNIX AND NOT CYGWIN)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
21 set(ARGS -f elf32)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
22 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
23 set(ARGS -f win32 -DPREFIX)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
24 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
25 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
26
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
27 if(GCC)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
28 list(APPEND ASM_FLAGS -DHAVE_ALIGNED_STACK=1)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
29 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
30 list(APPEND ASM_FLAGS -DHAVE_ALIGNED_STACK=0)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
31 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
32
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
33 if(HIGH_BIT_DEPTH)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
34 if(MAIN12)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
35 list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=12 -DX265_NS=${X265_NS})
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
36 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
37 list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10 -DX265_NS=${X265_NS})
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
38 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
39 else()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
40 list(APPEND ASM_FLAGS -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8 -DX265_NS=${X265_NS})
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
41 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
42
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
43 list(APPEND ASM_FLAGS '${CMAKE_ASM_NASM_FLAGS}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
44
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
45 if(CMAKE_BUILD_TYPE MATCHES Release)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
46 list(APPEND ASM_FLAGS '${CMAKE_ASM_NASM_FLAGS_RELEASE}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
47 elseif(CMAKE_BUILD_TYPE MATCHES Debug)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
48 list(APPEND ASM_FLAGS '${CMAKE_ASM_NASM_FLAGS_DEBUG}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
49 elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
50 list(APPEND ASM_FLAGS '${CMAKE_ASM_NASM_FLAGS_MINSIZEREL}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
51 elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
52 list(APPEND ASM_FLAGS '${CMAKE_ASM_NASM_FLAGS_RELWITHDEBINFO}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
53 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
54
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
55 set(NASM_FLAGS ${ARGS} ${ASM_FLAGS} PARENT_SCOPE)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
56 string(REPLACE ';' ' ' CMAKE_ASM_NASM_COMPILER_ARG1 '${ARGS}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
57
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
58 # This section exists to override the one in CMakeASMInformation.cmake
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
59 # (the default Information file). This removes the <FLAGS>
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
60 # thing so that your C compiler flags that have been set via
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
61 # set_target_properties don't get passed to nasm and confuse it.
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <vign[email protected]>
diffchangeset
62 if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
63 string(REPLACE ';' ' ' STR_ASM_FLAGS '${ASM_FLAGS}')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
64 set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT '<CMAKE_ASM${ASM_DIALECT}_COMPILER> ${STR_ASM_FLAGS} -o <OBJECT> <SOURCE>')
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
65 endif()
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
66
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
67 include(CMakeASMInformation)
ac3fda7e760cx86: Change assembler from YASM to NASM
Vignesh Vijayakumar <[email protected]>
diffchangeset
68 set(ASM_DIALECT)