Page MenuHomePhabricator

[CMAKE] Add compiler flags to properties rather than CFLAGS/CXXFLAGS
ClosedPublic

Authored by Fabien on Jan 15 2020, 13:53.

Details

Summary

This change the behavior of the add_(<LANG>_)compiler_flags macros.
Rather than editing the CFLAGS and/or CXXFLAGS, it adds the flag to the
COMPILE_OPTIONS property of the targets in the calling directory and
below that are added after this command is invoked.

The final goal is to avoid changing the CFLAGS/CXXFLAGS, because they
are not linked to target properties and are used in every build,
including the cmake checks such as check_cxx_source_compiles().

Depends on D4948.

Test Plan
ninja all check check-security

Run the Gitian builds.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cmake_compiler_flags_add_options
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 8957
Build 15887: Default Diff Build & Tests
Build 15886: arc lint + arc unit

Event Timeline

Snippet of first build failure:

[14:04:22] :	 [Step 1/1] [236/398] Building CXX object src/CMakeFiles/util.dir/util/moneystr.cpp.o
[14:04:29] :	 [Step 1/1] [237/398] Building CXX object src/CMakeFiles/server.dir/validationinterface.cpp.o
[14:04:30] :	 [Step 1/1] [238/398] Building CXX object src/CMakeFiles/util.dir/util/bytevectorhash.cpp.o
[14:04:34] :	 [Step 1/1] [239/398] Building CXX object src/CMakeFiles/util.dir/util/strencodings.cpp.o
[14:04:45] :	 [Step 1/1] [240/398] Building CXX object src/CMakeFiles/common.dir/cashaddr.cpp.o
[14:04:46] :	 [Step 1/1] [241/398] Building CXX object src/CMakeFiles/common.dir/amount.cpp.o
[14:04:48] :	 [Step 1/1] [242/398] Building CXX object src/CMakeFiles/common.dir/base58.cpp.o
[14:05:11] :	 [Step 1/1] [243/398] Building CXX object src/CMakeFiles/common.dir/config.cpp.o
[14:05:33] :	 [Step 1/1] [244/398] Building CXX object src/CMakeFiles/common.dir/consensus/merkle.cpp.o
[14:05:34] :	 [Step 1/1] [245/398] Building CXX object src/CMakeFiles/common.dir/cashaddrenc.cpp.o
[14:06:28] :	 [Step 1/1] [246/398] Building CXX object src/CMakeFiles/common.dir/compressor.cpp.o
[14:06:34] :	 [Step 1/1] [247/398] Building CXX object src/CMakeFiles/common.dir/coins.cpp.o
[14:07:16] :	 [Step 1/1] [248/398] Building CXX object src/CMakeFiles/common.dir/globals.cpp.o
[14:07:20] :	 [Step 1/1] [249/398] Building CXX object src/CMakeFiles/common.dir/feerate.cpp.o
[14:07:25] :	 [Step 1/1] [250/398] Building CXX object src/CMakeFiles/common.dir/chainparams.cpp.o
[14:07:25] :	 [Step 1/1] [251/398] Building CXX object src/CMakeFiles/util.dir/util/time.cpp.o
[14:07:33] :	 [Step 1/1] [252/398] Building CXX object src/CMakeFiles/util.dir/util/system.cpp.o
[14:07:35] :	 [Step 1/1] [253/398] Linking CXX static library src/libutil.a
[14:07:35] :	 [Step 1/1] [254/398] Linking CXX static library src/librpcclient.a
[14:07:38] :	 [Step 1/1] [255/398] Building CXX object src/CMakeFiles/common.dir/key.cpp.o
[14:07:40] :	 [Step 1/1] [256/398] Building CXX object src/CMakeFiles/common.dir/key_io.cpp.o
[14:07:41] :	 [Step 1/1] [257/398] Building CXX object src/CMakeFiles/server.dir/validation.cpp.o
[14:07:42] :	 [Step 1/1] [258/398] Building CXX object src/CMakeFiles/common.dir/netaddress.cpp.o
[14:07:43] :	 [Step 1/1] [259/398] Building CXX object src/CMakeFiles/common.dir/primitives/block.cpp.o
[14:07:46] :	 [Step 1/1] [260/398] Building CXX object src/CMakeFiles/common.dir/core_write.cpp.o
[14:07:47] :	 [Step 1/1] [261/398] Building CXX object src/CMakeFiles/common.dir/keystore.cpp.o
[14:07:48] :	 [Step 1/1] [262/398] Building CXX object src/CMakeFiles/common.dir/netbase.cpp.o
[14:07:48] :	 [Step 1/1] [263/398] Building CXX object src/CMakeFiles/common.dir/protocol.cpp.o
[14:07:48] :	 [Step 1/1] [264/398] Building CXX object src/CMakeFiles/common.dir/core_read.cpp.o
[14:07:49] :	 [Step 1/1] [265/398] Building CXX object src/CMakeFiles/script.dir/script/bitfield.cpp.o
[14:07:50] :	 [Step 1/1] [266/398] Building CXX object src/CMakeFiles/common.dir/warnings.cpp.o
[14:07:52] :	 [Step 1/1] [267/398] Building CXX object src/CMakeFiles/script.dir/script/script.cpp.o
[14:07:52] :	 [Step 1/1] [268/398] Building CXX object src/CMakeFiles/script.dir/script/script_error.cpp.o
[14:07:54] :	 [Step 1/1] [269/398] Building CXX object src/CMakeFiles/common.dir/scheduler.cpp.o
[14:07:54] :	 [Step 1/1] [270/398] Building CXX object src/CMakeFiles/script.dir/script/sigencoding.cpp.o
[14:07:56] :	 [Step 1/1] [271/398] Building CXX object src/CMakeFiles/script.dir/script/ismine.cpp.o
[14:07:58] :	 [Step 1/1] [272/398] Building CXX object src/CMakeFiles/bitcoin-cli.dir/bitcoin-cli.cpp.o
[14:08:00] :	 [Step 1/1] [273/398] Building CXX object src/CMakeFiles/script.dir/script/interpreter.cpp.o
[14:08:00] :	 [Step 1/1] [274/398] Linking C static library src/secp256k1/libsecp256k1.a
[14:08:00] :	 [Step 1/1] [275/398] Building CXX object src/CMakeFiles/bitcoinconsensus-shared.dir/script/bitcoinconsensus.cpp.o
[14:08:00] :	 [Step 1/1] [276/398] Linking C shared library src/secp256k1/libsecp256k1_jni.so
[14:08:00] :	 [Step 1/1] FAILED: src/secp256k1/libsecp256k1_jni.so 
[14:08:00] :	 [Step 1/1] : && /usr/bin/ccache /usr/bin/cc -fPIC -g -O2   -shared -Wl,-soname,libsecp256k1_jni.so -o src/secp256k1/libsecp256k1_jni.so src/secp256k1/CMakeFiles/secp256k1_jni.dir/src/java/org_bitcoin_NativeSecp256k1.c.o src/secp256k1/CMakeFiles/secp256k1_jni.dir/src/java/org_bitcoin_Secp256k1Context.c.o  src/secp256k1/libsecp256k1.a && :
[14:08:00] :	 [Step 1/1] /usr/bin/ld: src/secp256k1/libsecp256k1.a(secp256k1.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
[14:08:00] :	 [Step 1/1] /usr/bin/ld: final link failed: nonrepresentable section on output
[14:08:00] :	 [Step 1/1] collect2: error: ld returned 1 exit status
[14:08:00] :	 [Step 1/1] [277/398] Linking CXX static library src/libcommon.a
[14:08:01] :	 [Step 1/1] [278/398] Building CXX object src/CMakeFiles/script.dir/script/descriptor.cpp.o
[14:08:02] :	 [Step 1/1] [279/398] Building CXX object src/CMakeFiles/script.dir/script/standard.cpp.o
[14:08:02] :	 [Step 1/1] [280/398] Building CXX object src/CMakeFiles/bitcoind.dir/bitcoind.cpp.o
[14:08:03] :	 [Step 1/1] [281/398] Building CXX object src/CMakeFiles/script.dir/script/sign.cpp.o
[14:08:03] :	 [Step 1/1] ninja: build stopped: subcommand failed.
[14:08:03] :	 [Step 1/1] *** Output of /tmp/sanitizer_logs/*.log.* ***
[14:08:03]W:	 [Step 1/1] ++ print_sanitizers_log
[14:08:03]W:	 [Step 1/1] ++ for log in "${SAN_LOG_DIR}"/*.log.*
[14:08:03]W:	 [Step 1/1] ++ echo '*** Output of /tmp/sanitizer_logs/*.log.* ***'
[14:08:03]W:	 [Step 1/1] ++ cat '/tmp/sanitizer_logs/*.log.*'
[14:08:03]W:	 [Step 1/1] cat: '/tmp/sanitizer_logs/*.log.*': No such file or directory
[14:08:03]W:	 [Step 1/1] Process exited with code 1
[14:08:03]E:	 [Step 1/1] Process exited with code 1 (Step: Command Line)
Fabien planned changes to this revision.Jan 15 2020, 14:10

Need to investigate the failure

This revision is now accepted and ready to land.Jan 15 2020, 15:21