Skip to content

Commit 13b99e2

Browse files
Merge pull request #5610 from UdjinM6/wip_xcode15
build: make depends compilable with Xcode 15 on macos
2 parents 5ca6382 + aa7ba58 commit 13b99e2

File tree

4 files changed

+115
-2
lines changed

4 files changed

+115
-2
lines changed

depends/packages/boost.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ $(package)_config_opts_i686_android=address-model=32
2121
$(package)_config_opts_aarch64_android=address-model=64
2222
$(package)_config_opts_x86_64_android=address-model=64
2323
$(package)_config_opts_armv7a_android=address-model=32
24+
unary_function=unary_function
2425
ifneq (,$(findstring clang,$($(package)_cxx)))
2526
$(package)_toolset_$(host_os)=clang
27+
ifeq ($(build_os),darwin)
28+
unary_function=__unary_function
29+
endif
2630
else
2731
$(package)_toolset_$(host_os)=gcc
2832
endif
@@ -36,8 +40,10 @@ $(package)_cxxflags_x86_64=-fcf-protection=full
3640
endef
3741

3842
# Fix unused variable in boost_process, can be removed after upgrading to 1.72
43+
# Fix missing unary_function in clang15 on macos, can be removed after upgrading to 1.81
3944
define $(package)_preprocess_cmds
4045
sed -i.old "s/int ret_sig = 0;//" boost/process/detail/posix/wait_group.hpp && \
46+
sed -i.old "s/unary_function/$(unary_function)/" boost/container_hash/hash.hpp && \
4147
echo "using $($(package)_toolset_$(host_os)) : : $($(package)_cxx) : <cflags>\"$($(package)_cflags)\" <cxxflags>\"$($(package)_cxxflags)\" <compileflags>\"$($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$($(package)_ar)\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
4248
endef
4349

depends/packages/qt.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ $(package)_patches += rcc_hardcode_timestamp.patch
2323
$(package)_patches += duplicate_lcqpafonts.patch
2424
$(package)_patches += guix_cross_lib_path.patch
2525
$(package)_patches += fast_fixed_dtoa_no_optimize.patch
26+
$(package)_patches += fix-macos-linker.patch
27+
$(package)_patches += memory_resource.patch
2628

2729
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
2830
$(package)_qttranslations_sha256_hash=c92af4171397a0ed272330b4fa0669790fcac8d050b07c8b8cc565ebeba6735e
@@ -244,6 +246,7 @@ endef
244246
define $(package)_preprocess_cmds
245247
cp $($(package)_patch_dir)/qt.pro qt.pro && \
246248
cp $($(package)_patch_dir)/qttools_src.pro qttools/src/src.pro && \
249+
patch -p1 -i $($(package)_patch_dir)/fix-macos-linker.patch && \
247250
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \
248251
patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \
249252
patch -p1 -i $($(package)_patch_dir)/fix_qt_placeholders.patch && \
@@ -252,6 +255,7 @@ define $(package)_preprocess_cmds
252255
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_x86_64.patch && \
253256
patch -p1 -i $($(package)_patch_dir)/fix_montery_include.patch && \
254257
patch -p1 -i $($(package)_patch_dir)/use_android_ndk23.patch && \
258+
patch -p1 -i $($(package)_patch_dir)/memory_resource.patch && \
255259
patch -p1 -i $($(package)_patch_dir)/rcc_hardcode_timestamp.patch && \
256260
patch -p1 -i $($(package)_patch_dir)/duplicate_lcqpafonts.patch && \
257261
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
@@ -266,8 +270,7 @@ define $(package)_preprocess_cmds
266270
echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \
267271
echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \
268272
sed -i.old "s|QMAKE_CC = \$$$$\$$$${CROSS_COMPILE}clang|QMAKE_CC = $($(package)_cc)|" qtbase/mkspecs/common/clang.conf && \
269-
sed -i.old "s|QMAKE_CXX = \$$$$\$$$${CROSS_COMPILE}clang++|QMAKE_CXX = $($(package)_cxx)|" qtbase/mkspecs/common/clang.conf && \
270-
sed -i.old "s/error(\"failed to parse default search paths from compiler output\")/\!darwin: error(\"failed to parse default search paths from compiler output\")/g" qtbase/mkspecs/features/toolchain.prf
273+
sed -i.old "s|QMAKE_CXX = \$$$$\$$$${CROSS_COMPILE}clang++|QMAKE_CXX = $($(package)_cxx)|" qtbase/mkspecs/common/clang.conf
271274
endef
272275

273276
define $(package)_config_cmds
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
qmake: Don't error out if QMAKE_DEFAULT_LIBDIRS is empty on macOS
2+
3+
The new linker in Xcode 15 doesn't provide any default linker or
4+
framework paths when requested via -v, but still seems to use the
5+
default paths documented in the ld man page.
6+
7+
We trust that linker will do the right thing, even if we don't
8+
know of its default linker paths.
9+
10+
We also need to opt out of the default fallback logic to
11+
set the libdirs to /lib and /usr/lib.
12+
13+
This may result in UnixMakefileGenerator::findLibraries finding
14+
different libraries than expected, if additional paths are
15+
passed with -L, which will then take precedence for qmake,
16+
even if the linker itself will use the library from the
17+
SDK's default paths. This should hopefully not be an issue
18+
in practice, as we don't turn -lFoo into absolute paths in
19+
qmake, so the only risk is that we're picking up the wrong
20+
prl files and adding additional dependencies that the lib
21+
in the SDK doesn't have.
22+
23+
Upstream commits:
24+
- Qt 5.15.16: Not yet publicly available.
25+
- Qt dev: cdf64b0e47115cc473e1afd1472b4b09e130b2a5
26+
27+
For other Qt branches see
28+
https://codereview.qt-project.org/q/I2347b26e2df0828471373b0e15b8c9089274c65d
29+
30+
--- old/qtbase/mkspecs/features/toolchain.prf
31+
+++ new/qtbase/mkspecs/features/toolchain.prf
32+
@@ -283,9 +283,12 @@ isEmpty($${target_prefix}.INCDIRS) {
33+
}
34+
}
35+
}
36+
- isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS): \
37+
+ isEmpty(QMAKE_DEFAULT_INCDIRS): \
38+
!integrity: \
39+
- error("failed to parse default search paths from compiler output")
40+
+ error("failed to parse default include paths from compiler output")
41+
+ isEmpty(QMAKE_DEFAULT_LIBDIRS): \
42+
+ !integrity:!darwin: \
43+
+ error("failed to parse default library paths from compiler output")
44+
QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
45+
} else: ghs {
46+
cmd = $$QMAKE_CXX $$QMAKE_CXXFLAGS -$${LITERAL_HASH} -o /tmp/fake_output /tmp/fake_input.cpp
47+
@@ -407,7 +410,7 @@ isEmpty($${target_prefix}.INCDIRS) {
48+
QMAKE_DEFAULT_INCDIRS = $$split(INCLUDE, $$QMAKE_DIRLIST_SEP)
49+
}
50+
51+
- unix:if(!cross_compile|host_build) {
52+
+ unix:!darwin:if(!cross_compile|host_build) {
53+
isEmpty(QMAKE_DEFAULT_INCDIRS): QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include
54+
isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib
55+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Fix unusable memory_resource on macos
2+
3+
See https://bugreports.qt.io/browse/QTBUG-117484
4+
and https://bugreports.qt.io/browse/QTBUG-114316
5+
6+
--- a/qtbase/src/corelib/tools/qduplicatetracker_p.h
7+
+++ b/qtbase/src/corelib/tools/qduplicatetracker_p.h
8+
@@ -52,7 +52,7 @@
9+
10+
#include <qglobal.h>
11+
12+
-#if QT_HAS_INCLUDE(<memory_resource>) && __cplusplus > 201402L
13+
+#ifdef __cpp_lib_memory_resource
14+
# include <unordered_set>
15+
# include <memory_resource>
16+
#else
17+
18+
--- a/qtbase/src/corelib/global/qcompilerdetection.h
19+
+++ b/qtbase/src/corelib/global/qcompilerdetection.h
20+
@@ -1041,16 +1041,22 @@
21+
# endif // !_HAS_CONSTEXPR
22+
# endif // !__GLIBCXX__ && !_LIBCPP_VERSION
23+
# endif // Q_OS_QNX
24+
-# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \
25+
- && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
26+
+# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC)
27+
+# if defined(__GNUC_LIBSTD__) && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
28+
// Apple has not updated libstdc++ since 2007, which means it does not have
29+
// <initializer_list> or std::move. Let's disable these features
30+
-# undef Q_COMPILER_INITIALIZER_LISTS
31+
-# undef Q_COMPILER_RVALUE_REFS
32+
-# undef Q_COMPILER_REF_QUALIFIERS
33+
+# undef Q_COMPILER_INITIALIZER_LISTS
34+
+# undef Q_COMPILER_RVALUE_REFS
35+
+# undef Q_COMPILER_REF_QUALIFIERS
36+
// Also disable <atomic>, since it's clearly not there
37+
-# undef Q_COMPILER_ATOMICS
38+
-# endif
39+
+# undef Q_COMPILER_ATOMICS
40+
+# endif
41+
+# if defined(__cpp_lib_memory_resource) \
42+
+ && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000) \
43+
+ || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 170000))
44+
+# undef __cpp_lib_memory_resource // Only supported on macOS 14 and iOS 17
45+
+# endif
46+
+# endif // (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC)
47+
# if defined(Q_CC_CLANG) && defined(Q_CC_INTEL) && Q_CC_INTEL >= 1500
48+
// ICC 15.x and 16.0 have their own implementation of std::atomic, which is activated when in Clang mode
49+
// (probably because libc++'s <atomic> on OS X failed to compile), but they're missing some

0 commit comments

Comments
 (0)