View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014401CMakeCMakepublic2013-09-12 09:292016-06-10 14:31
ReporterPawel Defee 
Assigned ToAlex Neundorf 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformX86OSLinux 2.6.32-220.23.1.el6.i686OS VersionRedHat RHEL 6
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014401: CMake incorrectly passes C/CXX flags to assembler
DescriptionWhen building mixed C/CXX/ASM projects, CMake incorrectly passes C/CXX compiler options to assembler. On some platform (standard X86 GNU compilers), this is not an issue, but in my case where I cross-compile on X86 for ARM target, the assembler refuses to compile due to invalid options as follows:

[user@host temp]$ make
Scanning dependencies of target asmbug
[ 50%] Building CXX object CMakeFiles/asmbug.dir/main.cpp.obj
[100%] Building ASM object CMakeFiles/asmbug.dir/asmfunction.S.obj
/usr/local/embedded-cross-compilers/arm-eabi-as: unrecognized option '-O3'
make[2]: *** [CMakeFiles/asmbug.dir/asmfunction.S.obj] Error 1
make[1]: *** [CMakeFiles/asmbug.dir/all] Error 2
make: *** [all] Error 2
Steps To ReproduceRun CMake on the attached example project. This requires an arm cross compilation toolchain to be installed.
TagsNo tags attached.
Attached Filestar file icon asmbug.tar [^] (10,240 bytes) 2013-09-12 09:29

 Relationships

  Notes
(0033809)
Pawel Defee (reporter)
2013-09-12 09:33

I should add that it appears that this was broken after 2.8.4, i.e. 2.8.4 works fine.
(0033810)
Brad King (manager)
2013-09-12 09:40

IIRC there was an effort to use the C compiler as the default assembler, in which case passing the C flags makes sense.

Alex, what is the intended way to use a different assembler?
(0033811)
Alex Neundorf (developer)
2013-09-12 16:04

By default, for "ASM" the C compiler will be used as ASM compiler, i.e. CMAKE_ASM_COMPILER will be set to it.
This shouldn't mean that it receives C or C++ flags.

I tried it here, it doesn't look too bad:

make[2]: Entering directory `/home/alex/src/CMake/tests/asmbug-14401/build'
/opt/cmake-2.8.11.2-Linux-i386/bin/cmake -E cmake_progress_report /home/alex/src/CMake/tests/asmbug-14401/build/CMakeFiles 1
[ 50%] Building CXX object CMakeFiles/asmbug.dir/main.cpp.obj

/opt/eldk-4.1/arm/usr/bin/arm-linux-g++ -DCXX_FLAGS -O3 -DNDEBUG -o CMakeFiles/asmbug.dir/main.cpp.obj -c /home/alex/src/CMake/tests/asmbug-14401/main.cpp

/opt/cmake-2.8.11.2-Linux-i386/bin/cmake -E cmake_progress_report /home/alex/src/CMake/tests/asmbug-14401/build/CMakeFiles 2
[100%] Building ASM object CMakeFiles/asmbug.dir/asmfunction.S.obj

/opt/eldk-4.1/arm/usr/bin/arm-linux-as -DASM_FLAGS -O3 -DNDEBUG -o CMakeFiles/asmbug.dir/asmfunction.S.obj -c /home/alex/src/CMake/tests/asmbug-14401/asmfunction.S

The C++ file gets -DCXX_FLAGS and the S file gets -DASM_FLAGS, as they should.

There is the issue that as is used for "ASM". ASM is supposed to be used when the C/CXX compiler can be used for assembler too.
Here ASM-ATT should be used, i.e. CMAKE_ASM-ATT_COMPILER should be set, and the ASM-ATT language should be enabled.
The as doesn't receive the -O3 and -DNDEBUG flags.

I have to update the wiki page http://www.cmake.org/Wiki/CMake/Assembler [^]
(0033814)
Pawel Defee (reporter)
2013-09-13 02:55

Thanks for your suggestion. Adding the directive 'enable_language(ASM_ATT)' to our toolchain file did indeed solve the issue.

Please do update the wiki just in case someone else stumbles upon this same problem.

As far as I am concerned, this issue can be closed. Thanks again!
(0042364)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-09-12 09:29 Pawel Defee New Issue
2013-09-12 09:29 Pawel Defee File Added: asmbug.tar
2013-09-12 09:33 Pawel Defee Note Added: 0033809
2013-09-12 09:39 Brad King Assigned To => Alex Neundorf
2013-09-12 09:39 Brad King Status new => assigned
2013-09-12 09:40 Brad King Note Added: 0033810
2013-09-12 16:04 Alex Neundorf Note Added: 0033811
2013-09-13 02:55 Pawel Defee Note Added: 0033814
2016-06-10 14:29 Kitware Robot Note Added: 0042364
2016-06-10 14:29 Kitware Robot Status assigned => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team