Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SymCC fails to compile with -DTARGET_32BIT=ON #159

Open
PwnVerse opened this issue Mar 8, 2024 · 5 comments
Open

SymCC fails to compile with -DTARGET_32BIT=ON #159

PwnVerse opened this issue Mar 8, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@PwnVerse
Copy link

PwnVerse commented Mar 8, 2024

Here are the steps to reproduce the issue. Note that I have already built z3 separately.

git clone git@github.com:eurecom-s3/symcc.git
cd symcc 
git submodule init
git submodule update
mkdir build && cd build
cmake -G Ninja -DQSYM_BACKEND=ON -DTARGET_32BIT=ON -DZ3_TRUST_SYSTEM_VERSION=ON ..
ninja check

Fails with -

[9/22] Performing configure step for 'SymRuntime32'
FAILED: SymRuntime32-prefix/src/SymRuntime32-stamp/SymRuntime32-configure /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-stamp/SymRuntime32-configure 
cd /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build && /usr/bin/cmake -DCMAKE_AR=/usr/bin/ar -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_C_FLAGS= "-DCMAKE_C_FLAGS_INIT=  " -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_CXX_FLAGS= "-DCMAKE_CXX_FLAGS_INIT=  " -DCMAKE_EXE_LINKER_FLAGS= "-DCMAKE_EXE_LINKER_FLAGS_INIT=  " -DCMAKE_MAKE_PROGRAM=/home/ritvik/.local/bin/ninja -DCMAKE_MODULE_LINKER_FLAGS= "-DCMAKE_MODULE_LINKER_FLAGS_INIT=  " -DCMAKE_SHARED_LINKER_FLAGS= "-DCMAKE_SHARED_LINKER_FLAGS_INIT=  " -DCMAKE_MODULE_PATH=/home/ritvik/Desktop/Files/test/symcc/cmake -DCMAKE_SYSROOT= -DQSYM_BACKEND=ON -DCMAKE_BUILD_TYPE= -DZ3_TRUST_SYSTEM_VERSION=ON "-DCMAKE_C_FLAGS=\" -m32\"" "-DCMAKE_CXX_FLAGS=\" -m32\"" -DZ3_DIR= -DLLVM_DIR= -GNinja /home/ritvik/Desktop/Files/test/symcc/runtime && /usr/bin/cmake -E touch /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-stamp/SymRuntime32-configure
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/home/ritvik/.local/bin/ninja cmTC_a5f77 && [1/2] Building C object CMakeFiles/cmTC_a5f77.dir/testCCompiler.c.o
    FAILED: CMakeFiles/cmTC_a5f77.dir/testCCompiler.c.o 
    /usr/bin/cc   " -m32" -o CMakeFiles/cmTC_a5f77.dir/testCCompiler.c.o -c /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build/CMakeFiles/CMakeTmp/testCCompiler.c
    cc: warning:  -m32: linker input file unused because linking not done
    cc: error:  -m32: linker input file not found: No such file or directory
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:17 (project)


-- Configuring incomplete, errors occurred!
See also "/home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build/CMakeFiles/CMakeOutput.log".
See also "/home/ritvik/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build/CMakeFiles/CMakeError.log".
[12/22] Performing configure step for 'SymRuntime'
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Z3 (missing: Z3_DIR)
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ritvik/Desktop/Files/test/symcc/build/SymRuntime-prefix/src/SymRuntime-build
[14/22] Building CXX object CMakeFiles/Symbolize.dir/compiler/Pass.cpp.o
ninja: build stopped: subcommand failed.

The reason I see is that it's trying to use the -m32 flag as " -m32" in it's arguments. Please let me know if I'm missing something trivial.

@sebastianpoeplau
Copy link
Collaborator

I think you're right, and apparently nobody noticed in more than two years 😅 We'll need to have a look at how to fix this properly in CMake. As a workaround, can you try to give CMake some dummy C and C++ flags, either via -DCMAKE_[C/CXX]_FLAGS or with the CFLAGS/CXXFLAGS environment variables?

@sebastianpoeplau sebastianpoeplau added the bug Something isn't working label Mar 8, 2024
@PwnVerse
Copy link
Author

PwnVerse commented Mar 8, 2024

I tried setting the c and cxxflags to -emit-llvm this time, build succeeded but it ended up building the 64 bit version.

~/Desktop/Files/test/symcc/build/SymRuntime32-prefix/src/SymRuntime32-build$ file libSymRuntime.so
libSymRuntime.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=c8d49090c208303ec72d7bb414fcc0df5a5265bd, not stripped

@PwnVerse
Copy link
Author

@sebastianpoeplau I would like to investigate this further and either find a simple workaround or fix this issue for 32 bit builds. Is it possible for you to maybe hop on a quick call or give me some insight into how I can help in fixing this?

@Dang-Khoa
Copy link

Any updates on this bug? I'm also stuck on this.

@Dang-Khoa
Copy link

This error can be prevented by simply removing the leading space of the -m32 tags in the CMakeFile.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants