rizsotto / Bear

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

Multilib Issue #457

Closed tr4v3ler closed 1 year ago

tr4v3ler commented 2 years ago

Referring to wiki, I execute the following commands to compile 32-bit and 64 bit versions respectively:

# 32bit
mkdir build32 && cd build32
cmake -DCMAKE_C_COMPILER_ARG1="-m32" -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -DCMAKE_INSTALL_LIBDIR=lib/i386-linux-gnu ..
make all -j$(npr)
sudo make install

# 64bit
mkdir build64 && cd build64
cmake -DCMAKE_C_COMPILER_ARG1="-m64" -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu ..
make all -j$(npr)
sudo make install

But after that, the two libexec.so I got are both 64 bit with the same sha256.

rizsotto commented 2 years ago

Hey @tr4v3ler , thanks for the report. My first guess is that you are passing this to the C compiler and not to the CXX compiler.

tr4v3ler commented 2 years ago

Hey @tr4v3ler , thanks for the report. My first guess is that you are passing this to the C compiler and not to the CXX compiler.

Then I tried the following command:

# 32bit
cmake -DCMAKE_C_COMPILER_ARG1="-m32" -DCMAKE_CXX_COMPILER_ARG1="-m32" -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -DCMAKE_INSTALL_LIBDIR=lib/i386-linux-gnu ..

I still haven't got a 32-bit binary.

tr4v3ler commented 2 years ago

Hey @tr4v3ler , thanks for the report. My first guess is that you are passing this to the C compiler and not to the CXX compiler.

Then I tried the following command:

# 32bit
cmake -DCMAKE_C_COMPILER_ARG1="-m32" -DCMAKE_CXX_COMPILER_ARG1="-m32" -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -DCMAKE_INSTALL_LIBDIR=lib/i386-linux-gnu ..

I still haven't got a 32-bit binary.

In addition, I deleted the build32 directory and recreated it before execution, and then completed the compilation. After that, I still didn't generate a 32-bit shared library.

rizsotto commented 2 years ago

Thanks, to coming back... could you run the build in verbose mode? (set the environment variable VERBOSE=1 before running make) That case you can observe the compiler invocation.

Also you could try other CMake flags too. (CXX_FLAGS influence the build flags too, but that has to be set when you run CMake.)

Sorry for the confusion. The wiki page probably outdated, and I don't have the 32 bit libraries installed on my machine.

tr4v3ler commented 2 years ago

Thanks, to coming back... could you run the build in verbose mode? (set the environment variable VERBOSE=1 before running make) That case you can observe the compiler invocation.

Also you could try other CMake flags too. (CXX_FLAGS influence the build flags too, but that has to be set when you run CMake.)

Sorry for the confusion. The wiki page probably outdated, and I don't have the 32 bit libraries installed on my machine.

Now I use the following command:

cmake -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF -DENABLE_MULTILIB=ON -DCMAKE_INSTALL_LIBDIR=lib/i386-linux-gnu ..

But I meet this error when I execute make all -j$(nproc) :

[ 87%] Performing configure step for 'BearSource'
cd /home/tr4v3ler/data/tools/Bear/build32/subprojects/Build/BearSource && /usr/bin/cmake -DENABLE_UNIT_TESTS:BOOL=OFF -DENABLE_MULTILIB:BOOL=ON -DPKG_CONFIG_EXECUTABLE:PATH=/usr/bin/pkg-config "-GUnix Makefiles" -C/home/tr4v3ler/data/tools/Bear/build32/subprojects/tmp/BearSource/BearSource-cache-Release.cmake /home/tr4v3ler/data/tools/Bear/source
loading initial cache file /home/tr4v3ler/data/tools/Bear/build32/subprojects/tmp/BearSource/BearSource-cache-Release.cmake
Re-run cmake no build system arguments
CMake Error at CMakeLists.txt:27 (find_package):
  Could not find a configuration file for package "fmt" that is compatible
  with requested version "".

  The following configuration files were considered but not accepted:

    /home/tr4v3ler/data/tools/Bear/build32/subprojects/Install/fmt_dependency/lib/cmake/fmt/fmt-config.cmake, version: 8.1.1 (64bit)

-- Configuring incomplete, errors occurred!
See also "/home/tr4v3ler/data/tools/Bear/build32/subprojects/Build/BearSource/CMakeFiles/CMakeOutput.log".
See also "/home/tr4v3ler/data/tools/Bear/build32/subprojects/Build/BearSource/CMakeFiles/CMakeError.log".
make[2]: *** [CMakeFiles/BearSource.dir/build.make:112: subprojects/Stamp/BearSource/BearSource-configure] Error 1
make[2]: Leaving directory '/home/tr4v3ler/data/tools/Bear/build32'
make[1]: *** [CMakeFiles/Makefile2:182: CMakeFiles/BearSource.dir/all] Error 2
make[1]: Leaving directory '/home/tr4v3ler/data/tools/Bear/build32'
make: *** [Makefile:152: all] Error 2
rizsotto commented 2 years ago

Latest master has a fix to pass the relevant compiler flags to the 3rd party dependencies. (It's not yet released, so you need to build Bear from source.) Could you try that out?

nokia-git commented 1 year ago

I have this issue too. i have installed multi-lib, but still can not build 32 bit bear lib i got the log for reference

bear_log.txt

allen-c commented 1 year ago

I cann't build 32bit version on Ubuntu20.04 too. The build results always are 64bit version.

HIDE-r commented 4 months ago

The issue still exists for me too. The build results always are 64bit version.

fogcell commented 3 months ago

This same issue exists. 32-bit builds on multiple Ubuntu's still result in 64-bit.

i-ky commented 3 months ago

I was facing a similar issue and ended up developing my own compile_commands.json generator. See also #522.