summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-12-02 15:25:03 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-04 07:12:21 +0000
commit56d41d9b8b693eba38cf41aa5292843089f2361f (patch)
treee2b6855ae0195434019162be624a25fc1080cee1 /cmake
parentcc785b9b68d1b3b848be67e672dea91ee5715b7b (diff)
CMake: Fix arch parsing for oss-fuzz
I'll preface by saying, it's not clear to me why the behavior is different. Our qt_run_config_test_architecture function builds a target executable, and then uses file(STRINGS) to try and parse out some magic strings that we expect the executable to have (architecture, abi, etc). In qmake this was done by matching with a regular expression ending on a \\0 null byte character. In CMake, we do a string(FIND) and string(SUBSTRING until the end of the line) on a *line* returned from file(STRINGS). Notably, I did not find any regexp syntax provided by CMake to try and match a null byte character. Note the docs for file(STRINGS) implies to me that *lines* are detected by looking for newline characters '\n'. The docs also mention that binary data in the file is ignored. What's binary data though? If you open the executable with a hex editor, at least on macOS, the strings we are interested in are indeed separated by null byte chars, not newline chars. On most platforms file(STRINGS) did end a line on the null byte character. Except, for some reason not when building Qt for the oss-fuzz project with clang under Docker. Calling message() on one of the lines prints a very long string with null characters seemingly replaced with semicolons, and of course the matched architecture string is wrong and fails configuration. For *some reason*, if I add a "REGEX ==Qt=magic=Qt==" option to the file(STRINGS) command, the captured output lines don't contain semicolons even when building for oss-fuzz. The extracted strings are then correct, and configuration succeeds. Use the REGEX option workaround, with the aim to quickly fix Qt building for oss-fuzz for 6.0.1 release. Fixes: QTBUG-89047 Change-Id: Iad11c1090c1187aadd39082f196050bf3290df95 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit f071ba31b2e441268518217cbe2ec4fe1c978b31) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBaseConfigureTests.cmake3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake
index 50fc0c4fc0..af18131fcd 100644
--- a/cmake/QtBaseConfigureTests.cmake
+++ b/cmake/QtBaseConfigureTests.cmake
@@ -42,7 +42,8 @@ function(qt_run_config_test_architecture)
endif()
message(STATUS "Extracting architecture info from ${_arch_file}.")
- file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8)
+ file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8
+ REGEX "==Qt=magic=Qt==")
foreach (_line ${_arch_lines})
string(LENGTH "${_line}" lineLength)