CMake definition of CMAKE_ASM_COMPILE_OBJECT puts the flags after the source file, which makes it impossible to add -x ti-asm

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low

      Extract the attached zip file to an empty directory.  The CMakeLists.txt has these lines ...

      # For assembly files, add the option: -x ti-asm
      target_compile_options(
        stub
        PRIVATE $<$<COMPILE_LANGUAGE:ASM>:-x ti-asm>
      )
      

      Attempt a build with commands similar to ...

      C:\examples>cmake -B build . -DCMAKE_MAKE_PROGRAM=gmake -G"Unix Makefiles"
      -- The C compiler identification is TIClang 4.0.4
      -- The ASM compiler identification is TIClang
      -- Found assembler: C:/ti/compilers/ti-cgt-armllvm_4.0.4.LTS/bin/tiarmclang.exe
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/ti/compilers/ti-cgt-armllvm_4.0.4.LTS/bin/tiarmclang.exe - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Configuring done (32.2s)
      -- Generating done (0.4s)
      -- Build files have been written to: C:/examples/build
      
      C:\examples>cmake --build build --verbose
      Change Dir: 'C:/examples/build'
      
      Run Build Command(s): "C:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 gmake -f Makefile
      "C:/Program Files/CMake/bin/cmake.exe" -SC:/examples -BC:/examples/build --check-build-system CMakeFiles/Makefile.cmake 0
      "C:/Program Files/CMake/bin/cmake.exe" -E cmake_progress_start C:/examples/build/CMakeFiles C:/examples/build//CMakeFiles/progress.marks
      gmake  -f CMakeFiles/Makefile2 all
      gmake[1]: Entering directory 'C:/examples/build'
      gmake  -f CMakeFiles/stub.dir/build.make CMakeFiles/stub.dir/depend
      gmake[2]: Entering directory 'C:/examples/build'
      "C:/Program Files/CMake/bin/cmake.exe" -E cmake_depends "Unix Makefiles" C:/examples C:/examples C:/examples/build C:/examples/build C:/examples/build/CMakeFiles/stub.dir/DependInfo.cmake "--color="
      Dependee "C:/examples/build/CMakeFiles/stub.dir/DependInfo.cmake" is newer than depender "C:/examples/build/CMakeFiles/stub.dir/depend.internal".
      Dependee "C:/examples/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "C:/examples/build/CMakeFiles/stub.dir/depend.internal".
      Scanning dependencies of target stub
      gmake[2]: Leaving directory 'C:/examples/build'
      gmake  -f CMakeFiles/stub.dir/build.make CMakeFiles/stub.dir/build
      gmake[2]: Entering directory 'C:/examples/build'
      [ 33%] Building C object CMakeFiles/stub.dir/stub.c.obj
      C:/ti/compilers/ti-cgt-armllvm_4.0.4.LTS/bin/tiarmclang.exe -c C:/examples/stub.c    -MD -MT CMakeFiles/stub.dir/stub.c.obj -MF CMakeFiles/stub.dir/stub.c.obj.d -o CMakeFiles/stub.dir/stub.c.obj
      [ 66%] Building ASM object CMakeFiles/stub.dir/asm_code.o
      C:/ti/compilers/ti-cgt-armllvm_4.0.4.LTS/bin/tiarmclang.exe -c C:/examples/asm_code.asm   -x ti-asm -o CMakeFiles/stub.dir/asm_code.o
      tiarmclang: warning: '-x ti-asm' after last input file has no effect [-Wunused-command-line-argument]
      [100%] Linking C executable stub.out
      C:/ti/compilers/ti-cgt-armllvm_4.0.4.LTS/bin/tiarmclang.exe -Xlinker --output_file=stub.out -Xlinker --map_file=stub.map -Xlinker --rom_model "CMakeFiles/stub.dir/stub.c.obj" "CMakeFiles/stub.dir/asm_code.o"
      gmake[2]: Leaving directory 'C:/examples/build'
      [100%] Built target stub
      gmake[1]: Leaving directory 'C:/examples/build'
      "C:/Program Files/CMake/bin/cmake.exe" -E cmake_progress_start C:/examples/build/CMakeFiles 0
      

      Notice how the invocation of tiarmclang on asm_code.asm has -x ti-asm after the name of the file.  Thus a diagnostic issued about how -x ti-asm is ignored.   The only way to overcome this problem is by redefining CMAKE_ASM_COMPILE_OBJECT as follows:

      # Redefine variable for how assembly files are built, so the flags appear
      # BEFORE the source file
      set(CMAKE_ASM_COMPILE_OBJECT 
        "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c -o <OBJECT> <SOURCE>")
      

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-6025 - CMake definition of CMAKE_ASM_COMPI...
                SYNCHRONIZED
                • Last Sync Date: