From 840aa67146773d36c98fbdd0c446a1076551efaa Mon Sep 17 00:00:00 2001
From: Jake Petroules <jake.petroules@qt.io>
Date: Thu, 16 Feb 2017 23:44:22 -0800
Subject: [PATCH] Fix Bitcode handling for both makefile and Xcode generators

This fixes an issue which caused certain iOS projects to fail to link
when building with Xcode, and also fixes an issue where projects were
only ever built with -fembed-bitcode instead of -fembed-bitcode-marker
for debug builds with the makefile generator.

Task-number: QTBUG-58754
Change-Id: Icf0c9f0d64dbc0b38d6c48bf635c5383a78bd6d5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
---
 mkspecs/features/uikit/bitcode.prf | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mkspecs/features/uikit/bitcode.prf b/mkspecs/features/uikit/bitcode.prf
index a1dff19eb3..df298171c0 100644
--- a/mkspecs/features/uikit/bitcode.prf
+++ b/mkspecs/features/uikit/bitcode.prf
@@ -1,7 +1,13 @@
 lessThan(QMAKE_XCODE_VERSION, "7.0") {
     warning("You need to update Xcode to version 7 or newer to support bitcode")
-} else {
-    release:device {
+} else: !macx-xcode {
+    # Simulator builds and all debug builds SHOULD use -fembed-bitcode-marker,
+    # but unfortunately the -fembed-bitcode and -fembed-bitcode-marker driver
+    # flags do not work in conjunction with -Xarch, so we'll have to let it use
+    # the "wrong" flags for now (note that this issue affects only the Makefile
+    # generator). We also don't want the flags to be passed in Xcode builds, as
+    # the Xcode ENABLE_BITCODE setting will take care of that for us.
+    release {
         QMAKE_CFLAGS           += -fembed-bitcode
         QMAKE_CXXFLAGS         += -fembed-bitcode
         QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode