rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.83k stars 313 forks source link

Can cause link errors during cross compilation #555

Closed kenluobo closed 10 months ago

kenluobo commented 10 months ago

Describe the bug

  1. Bear will cause ld error, when I use it to generate compile database.
  2. build:
    compiler: aarch64-linux-gnu-gcc
    project: FFmpeg
    cmd: bear -- make -j 10
  3. Error message:
    CC      libavfilter/af_aexciter.o
    CC      libavfilter/af_afade.o
    CC      libavfilter/af_afftdn.o
    ERROR: ld.so: object '/usr/local/lib/x86_64-linux-gnu/bear/libexec.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
    ERROR: ld.so: object '/usr/local/lib/x86_64-linux-gnu/bear/libexec.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.

Expected behavior The compiled database will eventually be generated successfully, but hopefully no ld error will be reported.

Environment:

rizsotto commented 10 months ago

Could not reproduce.

$ ../configure --cross-prefix=aarch64-linux-gnu- --arch=aarch64 --target-os=linux
...
$ bear -- make -j12
...
$ file ffmpeg
ffmpeg: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=c69c188a69c94d1a39ae234c944513c686afdabc, for GNU/Linux 3.7.0, stripped
$ head compile_commands.json 
[
  {
    "arguments": [
      "/usr/bin/aarch64-linux-gnu-gcc",
      "-I.",
      "-Isrc/",
      "-D_ISOC99_SOURCE",
      "-D_FILE_OFFSET_BITS=64",
      "-D_LARGEFILE_SOURCE",
      "-D_POSIX_C_SOURCE=200112",