0

I'm producing dylibs with embedded bitcode and using the -bitcode-symbol-map flag to specify an output directory where files of the form UUID.bcsymbolmap get produced. I'd like to teach my build system about those bcsymbolmap files so I can install and package them, but it is hard to do so since the output name for the file is determined by the LC_UUID value in the dylib which seems to be determined by ld. It seems I have two choices:

  • Find a way to explicitly set the LC_UUID of the dylib when building it, so that I can predict the output name of the bcsymbolmap file.

  • Specify a well known name for the bcsymbolmap file (the -bitcode-symbol-map option does support this) which does not contain the UUID, and then at install time, figure out the LC_UUID of the associated dylib and rename the bcsymbolmap file appropriately.

However, I don't see either a linker flag that will let me specify the LC_UUID of the library when building it, or a tool to let me change it after the fact (thinking here of something like install_name_tool), nor do I see a utility that will easily give me back the LC_UUID of a given library (to do the needed renaming of the bcsymbolmap file), short of parsing the output of otool -l, which seems fragile and unpleasant.

I'd prefer to keep my options limited to things that ship with XCode. Does anyone know of tools to easily inject, edit, or emit the LC_UUID for a dylib?

acm
  • 12,183
  • 5
  • 39
  • 68
  • To clarify, I'm *not* using the XCode build system to here, I'm using a different build system, say, CMake or SCons. So suggestions on how to configure an XCode project to do this won't help. I'm looking for command line tools that can be invoked from my build system. – acm Oct 14 '18 at 20:00

1 Answers1

0

Found something slightly better than parsing otool -l output: running dwarfdump -u on the target will list the UUIDs:

$ dwarfdump -u build/libfoo.dylib
UUID: BF8FAFCC-5B1F-3FC8-B2AF-FCDA16609D71 (arm64) build/libfoo.dylib

It still isn't ideal, but at least is trivial to parse with awk or similar.

Apple engineers, if anyone ever sees this, it would be very build system friendly to add an option to ld to explicitly set the LC_UUID at build time. The flag -no_uuid already exists, it would seem easy to add a -uuid flag that took a UUID as an argument and used that instead of generating one.

acm
  • 12,183
  • 5
  • 39
  • 68