-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang with -flto argument result in File format not recognized
while linking
#242
Comments
Aha, figured this one out. Clang only supports LTO when using ld.gold, but arm64 still defaults to ld.bfd (not really a good reason for this any more I don't think, I should change that). To fix your Android.mk: # Gold does not support mips or mips64, but gold is needed for LTO with Clang.
ifeq (,$(filter $(TARGET_ARCH_ABI),mips mips64)
LOCAL_CFLAGS += -flto
LOCAL_LDFLAGS := -flto -fuse-ld=gold
endif |
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 9, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 9, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 11, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 11, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 11, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
username223
added a commit
to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings
that referenced
this issue
Apr 11, 2020
Using `-flto` on clang without using the gold linker produces the error: ```main.o: file not recognized: File format not recognized``` android/ndk#242 `gold` seems to be faster than `ld`, and decently tested even in 2010: https://stackoverflow.com/questions/3476093/replacing-ld-with-gold-any-experience Qmake will still append `-Wl,-O1` even though higher optimization levels are used. Removing this in order to keep the compile command as short as possible, and to reduce weird issues down the line. Ref topic: https://stackoverflow.com/questions/53384988/why-qmake-passes-wl-o1-to-gcc-when-linking-and-will-it-harm-lto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ndk-test.zip
Tested: NDK r13b
modify the Android.mk and remove the
LOCAL_CFLAGS += -flto
to make it compile.without
-flto
argument:The text was updated successfully, but these errors were encountered: