From b52b5fa082e76466640f286de23fb4695eb997ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 23 Jul 2014 13:19:39 +0200 Subject: 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 --- mkspecs/macx-ios-clang/rename_main.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'mkspecs') 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 \ +<&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) -- cgit v1.2.3