summaryrefslogtreecommitdiffstats
path: root/mkspecs/macx-ios-clang/rename_main.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mkspecs/macx-ios-clang/rename_main.sh')
-rwxr-xr-xmkspecs/macx-ios-clang/rename_main.sh21
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)