diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-07-23 13:19:39 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-07-23 13:46:44 +0200 |
commit | b52b5fa082e76466640f286de23fb4695eb997ed (patch) | |
tree | bd4681e30aabc6e7fc56c6fbeb6b3cf5de552c28 /mkspecs | |
parent | 07c0fdfe7a153babcfe448555377d63bb5e2916a (diff) |
iOS: Gracefully fail main()-renaming when link-time optimizations are enabled
We don't have a way to rename main() inside a LLVM bit-code file yet, so we
error out if we detect that LTO is enabled (which causes object files to be
written as LLVM bit-code), and inform the user about a workaround.
Task-number: QTBUG-40184
Change-Id: I89c927a3a7f075c65e54442c4f7e6bb25175b6f7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'mkspecs')
-rwxr-xr-x | mkspecs/macx-ios-clang/rename_main.sh | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/mkspecs/macx-ios-clang/rename_main.sh b/mkspecs/macx-ios-clang/rename_main.sh index b30eb160d0..b1321e855e 100755 --- a/mkspecs/macx-ios-clang/rename_main.sh +++ b/mkspecs/macx-ios-clang/rename_main.sh @@ -46,9 +46,26 @@ if [ $# -eq 0 ]; then else for f in $(find $1 -name '*.o'); do # Skip object files without the _main symbol - nm $f | grep -q 'T _main$' || continue + nm $f 2>/dev/null | grep -q 'T _main$' || continue - echo "Found main() in ${f#$1/}" + fname=${f#$1/} + + file -b $f | grep -qi 'llvm bit-code' && \ + (cat \ +<<EOF >&2 +$f:: error: The file '$fname' contains LLVM bitcode, not object code. Automatic main() redirection could not be applied. +note: This is most likely due to the use of link-time optimization (-flto). Please disable LTO, or work around the \ +issue by manually renaming your main() function to qtmn(): + +#ifdef Q_OS_IOS +extern "C" int qtmn(int argc, char *argv[]) +#else +int main(int argc, char *argv[]) +#endif +EOF + ) && exit 1 + + echo "Found main() in $fname" strings -t d - $f | grep '_main\(\.eh\)\?$' | while read match; do offset=$(echo $match | cut -d ' ' -f 1) |