4

I'm trying to make my app compatible with iOS 14 (Xcode 12.3). The build failed on linking stage with following error:

ld: linking module flags 'Dwarf Version': IDs have conflicting behaviors in 'xxx.o' and 'ld-temp.o'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've searched solutions below. The solution is to turn off Link-Time Optimization or change Link-Time Optimization from Monolithic to Incremental.

https://stackoverflow.com/questions/39125409/xcode-8-beta-6-conflicting-values-for-architecture
https://github.com/facebook/facebook-ios-sdk/issues/1560

I tried to change Link-Time Optimization from Monolithic to Incremental and it resolves my issue. So my question is:

  1. anyone know how to debug the root cause of this kind of linking conflict issue?
  2. why this linking conflict issue happens when building with iOS 14 but not in previous version?
  3. is changing LTO the only solution?
fan
  • 41
  • 1

1 Answers1

1

I had the same problem. In my case the xxx.o was a library that was compiled as bitcode. I analyzed the .o files within the library and they were no coff and no macho files. Instead they were wrapped bc files. see https://llvm.org/docs/BitCodeFormat.html

you can use file to analyse it. The problem is that the debug information of bitcode files is stored as Dwarf-2 while .o files do have Dwarf-4. Adding the -gdwarf-2 option did not work, because llvm compiles into bitcode first, which is dwarf2.

The fix is to convert the .o file that is a wrapped bc file to a real .o file by using llc. If you have a library it gets a bit more complicated, you need to exctract the wrapped .o files from the library first, convert them to real .o files and create a new library.