diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-04-24 16:43:14 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-04-24 16:43:14 +0300 |
commit | 29400a683f96867133b28299c0d0bd6bcf40df35 (patch) | |
tree | b616dfb91ce111d61a34a67b28069561306575da /mkspecs/features | |
parent | 42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (diff) | |
parent | 9c60c8b122e5eb74fe74e11b929c30aa19ec0dd3 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.10' into tqtc/lts-5.15-opensourcev5.15.10-lts-lgpl
Change-Id: Ic1bb4240ca70a8a361fa0267476707446579221d
Diffstat (limited to 'mkspecs/features')
-rw-r--r-- | mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in | 2 | ||||
-rwxr-xr-x | mkspecs/features/data/mac/objc_namespace.sh | 100 | ||||
-rw-r--r-- | mkspecs/features/default_post.prf | 9 | ||||
-rw-r--r-- | mkspecs/features/mac/sdk.mk | 2 | ||||
-rw-r--r-- | mkspecs/features/qt_common.prf | 2 |
5 files changed, 79 insertions, 36 deletions
diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in index 2e23109167..b465a7fa89 100644 --- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in +++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in @@ -87,7 +87,7 @@ string(CONCAT _plugin_genex # Add this plugin if all of the following are true: # 1) the list of explicitly included plugin types is empty # 2) the QT_PLUGIN_EXTENDS property for the plugin is empty or equal to one of the modules - # listed in the plugin's PLUGIN_EXTEND qmake variable + # listed in the plugin\'s PLUGIN_EXTEND qmake variable # 3) the user hasn\'t explicitly excluded the plugin. # TODO: Note that the current implementation of (2) is not entirely correct QTBUG-93501 \"$<AND:\" diff --git a/mkspecs/features/data/mac/objc_namespace.sh b/mkspecs/features/data/mac/objc_namespace.sh index ceff2df324..16af001fa8 100755 --- a/mkspecs/features/data/mac/objc_namespace.sh +++ b/mkspecs/features/data/mac/objc_namespace.sh @@ -42,7 +42,7 @@ script_argument_prefix="-Wobjc_namespace,--" required_arguments="target suffix original_ld" -optional_arguments="exclude_list exclude_regex slient" +optional_arguments="exclude_list exclude_regex silent" for argument in $required_arguments $optional_arguments; do declare "$argument=" @@ -100,11 +100,13 @@ sanitize_address() { echo "0x$address" } +arch_offset=0 read_binary() { local address=$1 local length=$2 - dd if="$target" bs=1 iseek=$address count=$length 2>|/dev/null + seek=$(($address + $arch_offset)) + dd if="$target" bs=1 iseek=$seek count=$length 2>|/dev/null } read_32bit_value() { @@ -112,23 +114,23 @@ read_32bit_value() { read_binary $address 4 | xxd -p | dd conv=swab 2>/dev/null | rev } -inspect_binary() { - inspect_mode="$1" +otool_args= +otool() { + command otool $otool_args $* +} - echo -n "đ Inspecting binary '$target', " - if [ ! -f "$target" ]; then - echo "target does not exist!" - exit 1 - fi +declare -a extra_classnames_files - read -a mach_header <<< "$(otool -h "$target" -v | tail -n 1)" - if [ "${mach_header[1]}" != "X86_64" ]; then - echo "binary is not 64-bit, only 64-bit binaries are supported!" - exit 1 - fi +inspect_binary() { + inspect_mode="$1" classnames_section="__objc_classname" classnames=$(otool -v -s __TEXT $classnames_section "$target" | tail -n +3) + if [ -z "$classnames" ]; then + echo " âšī¸ No Objective-C classes found in binary" + return 1 + fi + while read -a classname; do address=$(sanitize_address ${classname[0]}) name=${classname[1]} @@ -138,21 +140,26 @@ inspect_binary() { done <<< "$classnames" extra_classnames_file="$(mktemp -t ${classnames_section}_additions).S" + extra_classnames_files+=("$extra_classnames_file") if [ "$inspect_mode" == "inject_classnames" ]; then - echo "class names have not been namespaced, adding suffix '$suffix'..." + echo " âšī¸ Class names have not been namespaced, adding suffix '$suffix'..." printf ".section __TEXT,$classnames_section,cstring_literals,no_dead_strip\n" > $extra_classnames_file elif [ "$inspect_mode" == "patch_classes" ]; then - echo "found namespaced class names, updating class entries..." + echo " âšī¸ Found namespaced class names, updating class entries..." + fi + + classes=$(otool -o -v "$target" | grep "OBJC_CLASS_RO\|OBJC_METACLASS_RO") + if [ -z "$classes" ]; then + echo " đĨ Failed to read class entries from binary" + exit 1 fi - classes=$(otool -o -v "$target" | grep class_ro_t) while read -a class; do address="$(sanitize_address ${class[1]})" - class_flags="0x$(read_32bit_value $address)" if [ -z "$class_flags" ]; then - echo " đĨ failed to read class flags for class at $address" + echo " đĨ Failed to read class flags for class at $address" continue fi @@ -161,13 +168,13 @@ inspect_binary() { name_offset=$(($address + 24)) classname_address="0x$(read_32bit_value $name_offset)" if [ -z "$classname_address" ]; then - echo " đĨ failed to read class name address for class at $address" + echo " đĨ Failed to read class name address for class at $address" continue fi classname=$(get_entry address_to_classname $classname_address) if [ -z "$classname" ]; then - echo " đĨ failed to resolve class name for address '$classname_address'" + echo " đĨ Failed to resolve class name for address '$classname_address'" continue fi @@ -177,7 +184,7 @@ inspect_binary() { else class_type="class" fi - echo " đŊ skipping excluded $class_type '$classname'" + echo " đŊ Skipping excluded $class_type '$classname'" continue fi @@ -188,13 +195,13 @@ inspect_binary() { continue fi - echo " đ injecting $classnames_section entry '$newclassname' for '$classname'" + echo " đ Injecting $classnames_section entry '$newclassname' for '$classname'" printf ".asciz \"$newclassname\"\n" >> $extra_classnames_file elif [ "$inspect_mode" == "patch_classes" ]; then newclassname_address=$(get_entry classname_to_address ${newclassname}) if [ -z "$newclassname_address" ]; then - echo " đĨ failed to resolve class name address for class '$newclassname'" + echo " đĨ Failed to resolve class name address for class '$newclassname'" continue fi @@ -204,7 +211,9 @@ inspect_binary() { class_type="class" fi - echo " đ¨ patching class_ro_t at $address ($class_type) from $classname_address ($classname) to $newclassname_address ($newclassname)" + name_offset=$(($name_offset + $arch_offset)) + + echo " đ¨ Patching class_ro_t at $address ($class_type) from $classname_address ($classname) to $newclassname_address ($newclassname)" echo ${newclassname_address: -8} | rev | dd conv=swab 2>/dev/null | xxd -p -r -seek $name_offset -l 4 - "$target" fi done <<< "$classes" @@ -213,10 +222,43 @@ inspect_binary() { echo "đŠ Linking binary using '$original_ld'..." link_binary -inspect_binary inject_classnames +echo "đ Inspecting binary '$target'..." +if [ ! -f "$target" ]; then + echo " đĨ Target does not exist!" + exit 1 +fi -echo "đŠ Re-linking binary with extra __objc_classname section..." -link_binary $extra_classnames_file +read -a mach_header <<< "$(otool -h "$target" -v | tail -n 1)" +if [ "${mach_header[0]}" != "MH_MAGIC_64" ]; then + echo " đĨ Binary is not 64-bit, only 64-bit binaries are supported!" + exit 1 +fi + +architectures=$(otool -f -v $target | grep architecture) + +setup_arch() { + arch="$1" + if [ ! -z "$arch" ]; then + otool_args="-arch $arch" + offset=$(otool -f -v $target | grep -A 6 "architecture $arch" | grep offset) + offset="${offset##*( )}" + arch_offset="$(echo $offset | cut -d ' ' -f 2)" + echo "đ¤ Processing architecture '$arch' at offset $arch_offset..." + fi +} + +while read -a arch; do + setup_arch "${arch[1]}" + inspect_binary inject_classnames + if [ $? -ne 0 ]; then + exit + fi +done <<< "$architectures" -inspect_binary patch_classes +echo "đŠ Re-linking binary with extra __objc_classname section(s)..." +link_binary "${extra_classnames_files[@]}" +while read -a arch; do + setup_arch "${arch[1]}" + inspect_binary patch_classes +done <<< "$architectures" diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 462dbf7774..ac799047ab 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -122,17 +122,18 @@ breakpad { } c++17: CONFIG += c++1z -c++latest: CONFIG *= c++2a c++1z c++14 c++11 +c++latest: CONFIG *= c++2b c++2a c++1z c++14 c++11 -!c++11:!c++14:!c++1z:!c++2a { +!c++11:!c++14:!c++1z:!c++2a:!c++2b { # Qt requires C++11 since 5.7, check if we need to force a compiler option QT_COMPILER_STDCXX_no_L = $$replace(QT_COMPILER_STDCXX, "L$", "") !greaterThan(QT_COMPILER_STDCXX_no_L, 199711): CONFIG += c++11 } -c++11|c++14|c++1z|c++2a { +c++11|c++14|c++1z|c++2a|c++2b { # Disable special compiler flags for host builds !host_build|!cross_compile { - c++2a: cxxstd = CXX2A + c++2b: cxxstd = CXX2B + else: c++2a: cxxstd = CXX2A else: c++1z: cxxstd = CXX1Z else: c++14: cxxstd = CXX14 else: cxxstd = CXX11 diff --git a/mkspecs/features/mac/sdk.mk b/mkspecs/features/mac/sdk.mk index f30b5830b4..a32ceacb6c 100644 --- a/mkspecs/features/mac/sdk.mk +++ b/mkspecs/features/mac/sdk.mk @@ -1,6 +1,6 @@ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),) - CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1 + CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND)) ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION)) # We don't want to complain about out of date SDK unless the target needs to be remade. diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 269ec11be1..aed52752b7 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -18,6 +18,7 @@ qtConfig(c++11): CONFIG += c++11 strict_c++ qtConfig(c++14): CONFIG += c++14 qtConfig(c++1z): CONFIG += c++1z qtConfig(c++2a): CONFIG += c++2a +qtConfig(c++2b): CONFIG += c++2b qtConfig(c99): CONFIG += c99 qtConfig(c11): CONFIG += c11 qtConfig(separate_debug_info): CONFIG += separate_debug_info @@ -158,4 +159,3 @@ warnings_are_errors:warning_clean { } unset(ver) } - |