Skip to content

Commit

Permalink
depends: fix qt compilation for arm64-darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
div72 committed Sep 23, 2024
1 parent 2bb58be commit fdcb307
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 3 deletions.
10 changes: 8 additions & 2 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ $(package)_patches += fix_montery_include.patch
$(package)_patches += fix_android_jni_static.patch
$(package)_patches += dont_hardcode_pwd.patch
$(package)_patches += qtbase-moc-ignore-gcc-macro.patch
$(package)_patches += no_warnings_for_symbols.patch
$(package)_patches += duplicate_lcqpafonts.patch
$(package)_patches += clang_18_libpng.patch
$(package)_patches += no_qrhi.patch
$(package)_patches += drop_lrelease_dependency.patch
$(package)_patches += subdirs.pro
Expand All @@ -39,7 +42,7 @@ $(package)_config_opts_release += -silent
$(package)_config_opts_debug = -debug
$(package)_config_opts_debug += -optimized-tools
$(package)_config_opts += -bindir $(build_prefix)/bin
$(package)_config_opts += -c++std
$(package)_config_opts += -c++std $(CXX_STANDARD)
$(package)_config_opts += -confirm-license
$(package)_config_opts += -hostprefix $(build_prefix)
$(package)_config_opts += -no-compile-examples
Expand Down Expand Up @@ -139,7 +142,7 @@ ifneq ($(build_os),darwin)
$(package)_config_opts_darwin += -xplatform macx-clang-linux
$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK)
$(package)_config_opts_darwin += -device-option MAC_SDK_VERSION=$(OSX_SDK_VERSION)
$(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-"
$(package)_config_opts_darwin += -device-option CROSS_COMPILE="llvm-"
$(package)_config_opts_darwin += -device-option MAC_MIN_VERSION=$(OSX_MIN_VERSION)
$(package)_config_opts_darwin += -device-option MAC_TARGET=$(host)
$(package)_config_opts_darwin += -device-option XCODE_VERSION=$(XCODE_VERSION)
Expand Down Expand Up @@ -264,6 +267,9 @@ define $(package)_preprocess_cmds
patch -p1 -i $($(package)_patch_dir)/fix_android_jni_static.patch && \
patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
patch -p1 -i $($(package)_patch_dir)/no_warnings_for_symbols.patch && \
patch -p1 -i $($(package)_patch_dir)/clang_18_libpng.patch && \
patch -p1 -i $($(package)_patch_dir)/duplicate_lcqpafonts.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_montery_include.patch && \
patch -p1 -i $($(package)_patch_dir)/no_qrhi.patch && \
cp $($(package)_patch_dir)/subdirs.pro subdirs.pro && \
Expand Down
40 changes: 40 additions & 0 deletions depends/patches/qt/clang_18_libpng.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
fix Qt macOS build with Clang 18

See:
https://github.com/pnggroup/libpng/commit/893b8113f04d408cc6177c6de19c9889a48faa24.

In a similar manner as zlib (madler/zlib#895),
libpng contains a header configuration that's no longer valid and
hasn't been exercised for the macOS target.

- The target OS conditional macros are misused. Specifically
`TARGET_OS_MAC` covers all Apple targets, including iOS, and it
should not be checked with `#if defined` as they would always be
defined (to either 1 or 0) on Apple platforms.
- `#include <fp.h>` no longer works for the macOS target and results
in a compilation failure. macOS ships all required functions in
`math.h`, and clients should use `math.h` instead.

--- a/qtbase/src/3rdparty/libpng/pngpriv.h
+++ b/qtbase/src/3rdparty/libpng/pngpriv.h
@@ -514,18 +514,8 @@
*/
# include <float.h>

-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
- /* We need to check that <math.h> hasn't already been included earlier
- * as it seems it doesn't agree with <fp.h>, yet we should really use
- * <fp.h> if possible.
- */
-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
-# include <fp.h>
-# endif
-# else
-# include <math.h>
-# endif
+# include <math.h>
+
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
104 changes: 104 additions & 0 deletions depends/patches/qt/duplicate_lcqpafonts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
QtGui: Fix duplication of logging category lcQpaFonts

Move it to qplatformfontdatabase.h.

Upstream commit:
- Qt 6.0: ab01885e48873fb2ad71841a3f1627fe4d9cd835

--- a/qtbase/src/gui/text/qplatformfontdatabase.cpp
+++ b/qtbase/src/gui/text/qplatformfontdatabase.cpp
@@ -52,6 +52,8 @@

QT_BEGIN_NAMESPACE

+Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
+
void qt_registerFont(const QString &familyname, const QString &stylename,
const QString &foundryname, int weight,
QFont::Style style, int stretch, bool antialiased,

--- a/qtbase/src/gui/text/qplatformfontdatabase.h
+++ b/qtbase/src/gui/text/qplatformfontdatabase.h
@@ -50,6 +50,7 @@
//

#include <QtGui/qtguiglobal.h>
+#include <QtCore/qloggingcategory.h>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QList>
@@ -62,6 +63,7 @@

QT_BEGIN_NAMESPACE

+Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)

class QWritingSystemsPrivate;


--- a/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -86,8 +86,6 @@

QT_BEGIN_NAMESPACE

-Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
-
static float SYNTHETIC_ITALIC_SKEW = std::tan(14.f * std::acos(0.f) / 90.f);

bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length)

--- a/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -64,8 +64,6 @@

QT_BEGIN_NAMESPACE

-Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)
-
class QCoreTextFontEngine : public QFontEngine
{
Q_GADGET

--- a/qtbase/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/qtbase/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -68,8 +68,6 @@

QT_BEGIN_NAMESPACE

-Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
-
#ifndef QT_NO_DIRECTWRITE
// ### fixme: Consider direct linking of dwrite.dll once Windows Vista pre SP2 is dropped (QTBUG-49711)


--- a/qtbase/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h
+++ b/qtbase/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h
@@ -63,8 +63,6 @@

QT_BEGIN_NAMESPACE

-Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)
-
class QWindowsFontEngineData
{
Q_DISABLE_COPY_MOVE(QWindowsFontEngineData)

--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -40,6 +40,7 @@
#include "qgenericunixthemes_p.h"

#include "qpa/qplatformtheme_p.h"
+#include "qpa/qplatformfontdatabase.h"

#include <QtGui/QPalette>
#include <QtGui/QFont>
@@ -76,7 +77,6 @@
QT_BEGIN_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(qLcTray)
-Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")

ResourceHelper::ResourceHelper()
{
3 changes: 2 additions & 1 deletion depends/patches/qt/mac-qmake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH}
QMAKE_MAC_SDK.macosx.platform_name = macosx
QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION}
QMAKE_MAC_SDK.macosx.PlatformPath = /phony
QMAKE_CXXFLAGS += -fuse-ld=lld
!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET}
!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS
!host_build: QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
!host_build: QMAKE_CXXFLAGS += -target $${MAC_TARGET}
!host_build: QMAKE_LFLAGS += -target $${MAC_TARGET}
QMAKE_AR = $${CROSS_COMPILE}ar cq
QMAKE_RANLIB=$${CROSS_COMPILE}ranlib
Expand Down
11 changes: 11 additions & 0 deletions depends/patches/qt/no_warnings_for_symbols.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/qtbase/mkspecs/features/mac/no_warn_empty_obj_files.prf
+++ b/qtbase/mkspecs/features/mac/no_warn_empty_obj_files.prf
@@ -1,7 +1,7 @@
# Prevent warnings about object files without any symbols. This is a common
# thing in Qt as we tend to build files unconditionally, and then use ifdefs
# to compile out parts that are not relevant.
-QMAKE_RANLIB += -no_warning_for_no_symbols
+# QMAKE_RANLIB += -no_warning_for_no_symbols

# We have to tell 'ar' to not run ranlib by itself
QMAKE_AR += -S

0 comments on commit fdcb307

Please sign in to comment.