[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

binutils and llvm for cross-building



Hello!

I'm upstream for a project that I would like to be cross-buildable. Its
build uses the nm and llvm-objcopy tools (rationale below), and I want
these tools to be able to operate on cross-arch binaries. Notes:

- nm lives in the binutils package. I can
  Build-Depends:binutils-for-host and I can run $(HOST_ARCH)-nm in the
  build. This works. But I discovered that I don't even need to do that:
  it looks like the vanilla "nm" from binutils:amd64 is able to operate
  on arm64 binaries. Is this something that can be relied on? Do I need
  to bother with binutils-for-host and $(HOST_ARCH)-nm? Am I confused?

- llvm-objcopy lives in the llvm package. There's no llvm-for-host or
  $(HOST_ARCH)-llvm-objcopy, so I don't know how to make this work. Does
  anybody have ideas?


And now let me describe what I'm doing; there might be a much easier
way. I'm building libmrcal.so. I want to put a utility function in there
that uses symbols in libpython.so. This is a utility function that won't
be used 99% of the time, and I don't want to add a NEEDED tag on
libpython.so. It will only be used in a python process, so libpython.so
would be loaded anyway. So I build as usual, but then make the symbol
references to libpython weak, so the linker doesn't try to load it:

  gcc ... -o thing.o
  nm --undef thing.o ... > symbols
  llvm-objcopy --weaken-symbols=symbols thing.o

I haven't found a better way to do this. Suggestions?

Thanks!


Reply to: