Closed SweetVishnya closed 3 years ago
I am also experiencing it on my working Ubuntu 18.04.4. But I was not able to reproduce it in docker.
UPD: I was wrong. I am able to reproduce it on Ubuntu 18.04. Just replace the first line with:
sudo docker run --rm -it ubuntu:18.04 /bin/bash
Maybe, it is somehow connected with the newest Ubuntu updates.
It seems to be a problem with a new CMake. With older one DynamoRIO builds fine:
wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-x86_64.sh
modify file: ./build/core/CMakeFiles/dynamorio.dir/flags.make at line 6, change to: ASM_DEFINES = --def=dynamorio_EXPORTS
This file is dynamically modified, you need to update it after you meet the compilation error. [for maintainer] Changing configure file? can solve this?
But I still get linking error after eliminating 1. "-Werror" for signal.h, and 2. update "--defsys", when: Linking C shared library ../lib64/release/libdynamorio.so
I've also run into this, running on Ubuntu 18.04: https://github.com/trailofbits/mishegos/pull/252
(And for more context, all of GitHub Actions has recently switched to CMake 3.19 for ubuntu-latest
: https://github.com/actions/virtual-environments/pull/2159)
I did a quick search, and my educated guess is that this CMake helper file is probably the source of the problem: https://github.com/DynamoRIO/dynamorio/blob/master/make/cpp2asm_support.cmake. I'll keep looking into this.
In particular, this is suspect: https://github.com/DynamoRIO/dynamorio/blob/536cbd0a2f895294b9efa08d5bc35129f9bc2b8b/make/cpp2asm_support.cmake#L326-L341
It's calling the preprocessor first, so that's probably where the flag confusion is happening.
Our CI is still on Ubuntu 16.04 (could upgrade...but nobody wants to deal w/ the probably flaky tests that will flare up on any CI change...)
But, I now have cmake 3.18.4 locally and I do hit a problem:
$ cmake --version
cmake version 3.18.4
$ cmake -GNinja -DDEBUG=ON -DBUILD_TESTS=ON ../src && ninja
...
[103/1416] Building ASM object core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o
FAILED: core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o
/usr/bin/cpp -g --MD core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o.d -I/home/bruening/dr/git/src/core/drlibc -I/home/bruening/dr/git/src/core/ir/x86 -I/home/bruening/dr/git/src/core/arch/x86 -I/home/bruening/dr/git/src/core/unix -I/home/bruening/dr/git/src/core/ir -I/home/bruening/dr/git/src/core/arch -I/home/bruening/dr/git/src/core/lib -I. -Iinclude/annotations -DCPP2ASM -E /home/bruening/dr/git/src/core/arch/x86/memfuncs.asm -o core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o.s && /usr/bin/cmake -Dfile=core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o.s -P "/home/bruening/dr/git/src/make/CMake_asm.cmake" && /usr/bin/as -mmnemonic=intel -msyntax=intel -mnaked-reg --64 --noexecstack -g -o core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o.s
cpp: error: core/CMakeFiles/drmemfuncs.dir/arch/x86/memfuncs.asm.o.d: No such file or directory
cpp: error: unrecognized command-line option ‘--MD’; did you mean ‘-MD’?
cpp: fatal error: no input files
compilation terminated.
It looks like Ubuntu 16.04 on Github Actions suddenly upgraded CMake and is hitting this: https://github.com/DynamoRIO/dynamorio/pull/4580/checks?check_run_id=1494251904
debug-internal-64: **** 19 build errors ****
cpp: error: STATIC_LIBRARY: No such file or directory
cpp: error: unrecognized command line option ‘--defsym’
core/CMakeFiles/dynamorio_static_nohide.dir/build.make:838: recipe for target 'core/CMakeFiles/dynamorio_static_nohide.dir/arch/x86/x86.asm.o' failed
make[2]: *** [core/CMakeFiles/dynamorio_static_nohide.dir/arch/x86/x86.asm.o] Error 1
make[1]: *** [core/CMakeFiles/dynamorio_static_nohide.dir/all] Error 2
CMakeFiles/Makefile2:2302: recipe for target 'core/CMakeFiles/dynamorio_static_nohide.dir/all' failed
cpp: error: dynamorio_EXPORTS: No such file or directory
cpp: error: unrecognized command line option ‘--defsym’
core/CMakeFiles/dynamorio.dir/build.make:838: recipe for target 'core/CMakeFiles/dynamorio.dir/arch/x86/x86.asm.o' failed
make[2]: *** [core/CMakeFiles/dynamorio.dir/arch/x86/x86.asm.o] Error 1
They're on 3.19 and it also complains here:
2020-12-03T13:55:57.4900065Z CMake Deprecation Warning at /home/runner/work/dynamorio/dynamorio/suite/runsuite.cmake:32 (cmake_minimum_required):
2020-12-03T13:55:57.4901325Z Compatibility with CMake < 2.8.12 will be removed from a future version of
2020-12-03T13:55:57.4902031Z CMake.
2020-12-03T13:55:57.4902333Z
2020-12-03T13:55:57.4902845Z Update the VERSION argument <min> value or use a ...<max> suffix to tell
2020-12-03T13:55:57.4903575Z CMake that the project does not need compatibility with older versions.
@abhinav92003 pointed to the GA failures coming from this recent update: https://github.com/actions/virtual-environments/pull/2159
@abhinav92003 pointed to the GA failures coming from this recent update: actions/virtual-environments#2159
Actually I came to know of it from woodruffw's comment above :)
Locally, if I solve the --MD
issue, I then repro the --defsym
error.
After solving that I then hit this:
/usr/bin/ld: core/CMakeFiles/unit_tests.dir/arch/x86/x86.asm.o: in function `_start':
/home/bruening/dr/git/src/core/arch/x86/x86.asm:1158: multiple definition of `_start'; /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o:(.text+0x0): first defined here
/usr/bin/ld: core/CMakeFiles/unit_tests.dir/arch/x86/x86.asm.o: in function `_start':
/home/bruening/dr/git/src/core/arch/x86/x86.asm:1165: undefined reference to `relocate_dynamorio'
/usr/bin/ld: core/CMakeFiles/unit_tests.dir/arch/x86/x86.asm.o: in function `reloaded_xfer':
/home/bruening/dr/git/src/core/arch/x86/x86.asm:1179: undefined reference to `privload_early_inject'
collect2: error: ld returned 1 exit status
So we have two issues:
1) The CMake-generated define -Ddynamorio_EXPORTS
is being passed as --defsym dynamorio_EXPORTS
in <DEFINES>
for asm targets, but we pass that to cpp
.
2) Various compiler flags like --MD
are in <FLAGS>
and cpp
does not like them.
My solution is to:
1) set(CMAKE_ASM_DEFINE_FLAG "-D")
2) Remove <FLAGS>
from the cpp
command for asm.
3) Move all of our preprocessor defines from COMPILE_FLAGS
properties with explicit -D
to COMPILE_DEFINITIONS
properites without -D
so we get them in <DEFINES>
.
I have that big switch from COMPILE_FLAGS
to COMPILE_DEFINITIONS
working for everything except the avx tests which want the built-in compiler defs like __AVX__
in the asm code: and it's not there now. Trying to solve this last bit.
commit 12496fe8bb2636fb8df66bca211469b967795414
I get the following compilation error.