blob: 94e0fbe0deadd084360da8593c29adcf410913f1 [file] [log] [blame] [edit]
#
# W A R N I N G
# -------------
#
# This file is not part of the Qt API. It exists purely as an
# implementation detail. It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#
# The Objective-C runtime will complain when loading a binary that
# introduces as class name that already exists in the global namespace.
# This may happen when linking Qt statically into a plugin, and then
# loading more than two plugins into the same host, both using Qt.
#
# We work around this by doing a bit of post-processing on the final
# binary, adding new suffixed class name entries to the __objc_classname
# section of the __TEXT segment, and then patching the class_ro_t
# entries to point to the newly added class names.
#
# By linking the binary between these two steps we avoid having to
# manually remap all the offsets in the Mach-O binary due to the
# added class names, instead relying on the linker to do this
# for us by linking in an assembly file with the added names.
objc_namespace_script = $$clean_path($$PWD/../../data/mac/objc_namespace.sh)
isEmpty(QMAKE_OBJC_NAMESPACE_SUFFIX) {
QMAKE_OBJC_NAMESPACE_SUFFIX = $$TARGET
!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \
QMAKE_OBJC_NAMESPACE_SUFFIX = $${QMAKE_TARGET_BUNDLE_PREFIX}.$${QMAKE_OBJC_NAMESPACE_SUFFIX}
}
QMAKE_LFLAGS += \
-Wobjc_namespace,--target=$$shell_quote($$TARGET) \
-Wobjc_namespace,--suffix=$$shell_quote($$QMAKE_OBJC_NAMESPACE_SUFFIX) \
-Wobjc_namespace,--original_ld=$$shell_quote($$QMAKE_LINK)
!isEmpty(QMAKE_OBJC_NAMESPACE_EXCLUDE): \
QMAKE_LFLAGS += -Wobjc_namespace,--exclude_list=$$shell_quote($$QMAKE_OBJC_NAMESPACE_EXCLUDE)
!isEmpty(QMAKE_OBJC_NAMESPACE_EXCLUDE_REGEX) {
equals(MAKEFILE_GENERATOR, UNIX): \
QMAKE_OBJC_NAMESPACE_EXCLUDE_REGEX ~= s/\\$/\$\$/
QMAKE_LFLAGS += -Wobjc_namespace,--exclude_regex=$$shell_quote($$QMAKE_OBJC_NAMESPACE_EXCLUDE_REGEX)
}
slient: QMAKE_LFLAGS += -Wobjc_namespace,--silent=1
QMAKE_LINK = $$objc_namespace_script