rui314 / mold

Mold: A Modern Linker 🦠
MIT License
14.13k stars 464 forks source link

build-static.sh fails #84

Closed pacak closed 3 years ago

pacak commented 3 years ago

On 50b7497 I get this

+ set -e                                                                                                                                                                                                                                      
+ '[' -f mold ']'
+ cat                                                                                                                                                                                                                                         
+ docker build -t mold-build-ubuntu20 -                                                                                                                                                                                                       
Sending build context to Docker daemon  2.048kB                                                                                                                                                                                               
Step 1/2 : FROM ubuntu:20.04                                                                                                                                                                                                                  
 ---> 9873176a8ff5
Step 2/2 : RUN apt-get update &&   TZ=Europe/London apt-get install -y tzdata &&   apt-get install -y build-essential git clang lld cmake     libstdc++-10-dev libxxhash-dev zlib1g-dev libssl-dev &&   rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> e46d3bf61cc1
Successfully built e46d3bf61cc1
Successfully tagged mold-build-ubuntu20:latest                                                                                                                                                                                                
++ pwd                                                                                                                                                                                                                                        
++ id -u                                                                                                                                                                                                                                      
++ id -g                                                                                                                                                                                                                                      
++ nproc                                                                                                                                                                                                                                      
+ docker run -it --rm -v /home/pacak/github/mold:/mold -u 1000:1000 mold-build-ubuntu20 make -C /mold -j12 'EXTRA_LDFLAGS=-fuse-ld=lld -static'                                                                                               
make: Entering directory '/mold'                                                                                                                                                                                                              
mkdir -p oneTBB/out
(cd oneTBB/out; cmake -DBUILD_SHARED_LIBS=OFF -DTBB_TEST=OFF -DCMAKE_CXX_FLAGS=-D__TBB_DYNAMIC_LOAD_ENABLED=0 ..)                                                                                                                             
CMake Warning at CMakeLists.txt:109 (message):                                                                                                                                                                                                
  You are building oneTBB as a static library.  This is highly discouraged
  and such configuration is not supported.  Consider building a dynamic
  library to avoid unforeseen issues.

Usage: cmake -DTBB_ROOT=<tbb_root> -DTBB_OS=Linux|Windows|Darwin [-DSAVE_TO=<path>] -P tbb_config_generator.cmake
CMake Error at cmake/tbb_config_generator.cmake:21 (message):
  Required parameter TBB_ROOT is not defined
Call Stack (most recent call first):
  CMakeLists.txt:177 (include)

-- Configuring incomplete, errors occurred!
See also "/mold/oneTBB/out/CMakeFiles/CMakeOutput.log".
See also "/mold/oneTBB/out/CMakeFiles/CMakeError.log".
make: *** [Makefile:81: oneTBB/out/libs/libtbb.a] Error 1
make: Leaving directory '/mold'
elakelaiset% make clean                                                                                                                                                                                                          ~/github/mold
rm -rf *.o *~ mold mold-wrapper.so test/tmp mimalloc/out oneTBB/out ld                                                                                                                                                                        
elakelaiset% ./build-static.sh                                                                                                                                                                                                   ~/github/mold
+ set -e                                                                                                                                                                                                                                      
+ '[' -f mold ']'                                                                                                                                                                                                                             
+ cat                                                                                                                                                                                                                                         
+ docker build -t mold-build-ubuntu20 -                                                                                                                                                                                                       
Sending build context to Docker daemon  2.048kB                                                                                                                                                                                               
Step 1/2 : FROM ubuntu:20.04                                                                                                                                                                                                                  
 ---> 9873176a8ff5                                                                                                                                                                                                                            
Step 2/2 : RUN apt-get update &&   TZ=Europe/London apt-get install -y tzdata &&   apt-get install -y build-essential git clang lld cmake     libstdc++-10-dev libxxhash-dev zlib1g-dev libssl-dev &&   rm -rf /var/lib/apt/lists/*           
 ---> Using cache                                                                                                                                                                                                                             
 ---> e46d3bf61cc1
Successfully built e46d3bf61cc1                                                                                                                                                                                                               
Successfully tagged mold-build-ubuntu20:latest                                                                                                                                                                                                
++ pwd                                                                                                                                                                                                                                        
++ id -u                                                                                                                                                                                                                                      
++ id -g                                                                                                                                                                                                                                      
++ nproc                                                                                                                                                                                                                                      
+ docker run -it --rm -v /home/pacak/github/mold:/mold -u 1000:1000 mold-build-ubuntu20 make -C /mold -j12 'EXTRA_LDFLAGS=-fuse-ld=lld -static'                                                                                               
make: Entering directory '/mold'                                                                                                                                                                                                              
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o main.o main.cc                                                               
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o object_file.o object_file.cc                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o input_sections.o input_sections.cc                                           
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o output_chunks.o output_chunks.cc                                             
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o mapfile.o mapfile.cc                                                         
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o perf.o perf.cc                                                               
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o linker_script.o linker_script.cc                                             
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o archive_file.o archive_file.cc                                               
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o output_file.o output_file.cc                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o subprocess.o subprocess.cc                                                   
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o gc_sections.o gc_sections.cc                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o icf.o icf.cc                                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o symbols.o symbols.cc                                                         
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o cmdline.o cmdline.cc                                                         
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o filepath.o filepath.cc                                                       
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o passes.o passes.cc                                                           
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o tar.o tar.cc                                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o compress.o compress.cc                                                       
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o memory_mapped_file.o memory_mapped_file.cc                                   
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o relocatable.o relocatable.cc                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o arch_x86_64.o arch_x86_64.cc                                                 
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o arch_i386.o arch_i386.cc                                                     
clang++  -g -Imimalloc/include -pthread -std=c++20 -DMOLD_VERSION=\"0.9.1\" -DGIT_HASH=\"50b7497e19accedb0750d806b208a6c273a5c7c8\"  -O2 -IoneTBB/include  -c -o arch_aarch64.o arch_aarch64.cc                                               
mkdir -p mimalloc/out/release                                                                                                                                                                                                                 
(cd mimalloc/out/release; CFLAGS=-DMI_USE_ENVIRON=0 cmake ../..)                                                                                                                                                                              
-- The C compiler identification is GNU 9.3.0                                                                                                                                                                                                 
-- The CXX compiler identification is GNU 9.3.0                                                                                                                                                                                               
-- Check for working C compiler: /usr/bin/cc                                                                                                                                                                                                  
-- Check for working C compiler: /usr/bin/cc -- works                                                                                                                                                                                         
-- Detecting C compiler ABI info                                                                                                                                                                                                              
-- Detecting C compiler ABI info - done                                                                                                                                                                                                       
-- Detecting C compile features                                                                                                                                                                                                               
-- Detecting C compile features - done                                                                                                                                                                                                        
-- Check for working CXX compiler: /usr/bin/c++                                                                                                                                                                                               
-- Check for working CXX compiler: /usr/bin/c++ -- works                                                                                                                                                                                      
-- Detecting CXX compiler ABI info                                                                                                                                                                                                            
-- Detecting CXX compiler ABI info - done                                                                                                                                                                                                     
-- Detecting CXX compile features                                                                                                                                                                                                             
-- Detecting CXX compile features - done                                                                                                                                                                                                      
-- No build type selected, default to: Release                                                                                                                                                                                                
-- Override standard malloc (MI_OVERRIDE=ON)                                                                                                                                                                                                  
--                                                                                                                                                                                                                                            
-- Library base name: mimalloc                                                                                                                                                                                                                
-- Build type       : release                                                                                                                                                                                                                 
-- Compiler         : /usr/bin/cc                                                                                                                                                                                                             
-- Install directory: /usr/local/lib/mimalloc-1.7                                                                                                                                                                                             
-- Build targets    : shared;static;object;tests                                                                                                                                                                                              
--                                                                                                                                                                                                                                            
-- Configuring done                                                                                                                                                                                                                           
-- Generating done                                                                                                                                                                                                                            
-- Build files have been written to: /mold/mimalloc/out/release                                                                                                                                                                               
make -C mimalloc/out/release mimalloc-static                                                                                                                                                                                                  
make[1]: Entering directory '/mold/mimalloc/out/release'                                                                                                                                                                                      
make[2]: Entering directory '/mold/mimalloc/out/release'                                                                                                                                                                                      
make[3]: Entering directory '/mold/mimalloc/out/release'                                                                                                                                                                                      
make[4]: Entering directory '/mold/mimalloc/out/release'                                                                                                                                                                                      
Scanning dependencies of target mimalloc-static                                                                                                                                                                                               
make[4]: Leaving directory '/mold/mimalloc/out/release'                                                                                                                                                                                       
make[4]: Entering directory '/mold/mimalloc/out/release'                                                                                                                                                                                      
[  6%] Building C object CMakeFiles/mimalloc-static.dir/src/stats.c.o                                                                                                                                                                         
mkdir -p oneTBB/out                                                                                                                                                                                                                           
(cd oneTBB/out; cmake -DBUILD_SHARED_LIBS=OFF -DTBB_TEST=OFF -DCMAKE_CXX_FLAGS=-D__TBB_DYNAMIC_LOAD_ENABLED=0 ..)                                                                                                                             
-- The CXX compiler identification is GNU 9.3.0                                                                                                                                                                                               
-- Check for working CXX compiler: /usr/bin/c++                                                                                                                                                                                               
[ 13%] Building C object CMakeFiles/mimalloc-static.dir/src/random.c.o                                                                                                                                                                        
-- Check for working CXX compiler: /usr/bin/c++ -- works                                                                                                                                                                                      
-- Detecting CXX compiler ABI info                                                                                                                                                                                                            
-- Detecting CXX compiler ABI info - done                                                                                                                                                                                                     
-- Detecting CXX compile features                                                                                                                                                                                                             
-- Detecting CXX compile features - done                                                                                                                                                                                                      
CMake Warning at CMakeLists.txt:109 (message):                                                                                                                                                                                                
  You are building oneTBB as a static library.  This is highly discouraged                                                                                                                                                                    
  and such configuration is not supported.  Consider building a dynamic                                                                                                                                                                       
  library to avoid unforeseen issues.                                                                                                                                                                                                         

-- CMAKE_BUILD_TYPE is not specified. Using default: RelWithDebInfo                                                                                                                                                                           
-- Looking for C++ include pthread.h                                                                                                                                                                                                          
[ 20%] Building C object CMakeFiles/mimalloc-static.dir/src/os.c.o                                                                                                                                                                            
clang -fPIC -shared -o mold-wrapper.so mold-wrapper.c -ldl                                                                                                                                                                                    
-- Looking for C++ include pthread.h - found                                                                                                                                                                                                  
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD                                                                                                                                                                                                    
[ 26%] Building C object CMakeFiles/mimalloc-static.dir/src/bitmap.c.o                                                                                                                                                                        
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed                                                                                                                                                                                           
-- Check if compiler accepts -pthread                                                                                                                                                                                                         
[ 33%] Building C object CMakeFiles/mimalloc-static.dir/src/arena.c.o                                                                                                                                                                         
[ 40%] Building C object CMakeFiles/mimalloc-static.dir/src/segment.c.o                                                                                                                                                                       
[ 46%] Building C object CMakeFiles/mimalloc-static.dir/src/region.c.o
-- Check if compiler accepts -pthread - yes                                                                                                                                                                                                   
-- Found Threads: TRUE                                                                                                                                                                                                                        
Usage: cmake -DTBB_ROOT=<tbb_root> -DTBB_OS=Linux|Windows|Darwin [-DSAVE_TO=<path>] -P tbb_config_generator.cmake                                                                                                                             
CMake Error at cmake/tbb_config_generator.cmake:21 (message):                                                                                                                                                                                 
  Required parameter TBB_ROOT is not defined                                                                                                                                                                                                  
Call Stack (most recent call first):                                                                                                                                                                                                          
  CMakeLists.txt:177 (include)                                                                                                                                                                                                                

-- Configuring incomplete, errors occurred!                                                                                                                                                                                                   
See also "/mold/oneTBB/out/CMakeFiles/CMakeOutput.log".                                                                                                                                                                                       
See also "/mold/oneTBB/out/CMakeFiles/CMakeError.log".                                                                                                                                                                                        
make: *** [Makefile:81: oneTBB/out/libs/libtbb.a] Error 1                                                                                                                                                                                     
make: *** Waiting for unfinished jobs....                                                                                                                                                                                                     
[ 53%] Building C object CMakeFiles/mimalloc-static.dir/src/page.c.o                                                                                                                                                                          
[ 60%] Building C object CMakeFiles/mimalloc-static.dir/src/alloc.c.o                                                                                                                                                                         
[ 66%] Building C object CMakeFiles/mimalloc-static.dir/src/alloc-aligned.c.o                                                                                                                                                                 
[ 73%] Building C object CMakeFiles/mimalloc-static.dir/src/alloc-posix.c.o                                                                                                                                                                   
[ 80%] Building C object CMakeFiles/mimalloc-static.dir/src/heap.c.o                                                                                                                                                                          
[ 86%] Building C object CMakeFiles/mimalloc-static.dir/src/options.c.o                                                                                                                                                                       
[ 93%] Building C object CMakeFiles/mimalloc-static.dir/src/init.c.o                                                                                                                                                                          
[100%] Linking C static library libmimalloc.a                                                                                                                                                                                                 
make[4]: Leaving directory '/mold/mimalloc/out/release'                                                                                                                                                                                       
[100%] Built target mimalloc-static                                                                                                                                                                                                           
make[3]: Leaving directory '/mold/mimalloc/out/release'                                                                                                                                                                                       
make[2]: Leaving directory '/mold/mimalloc/out/release'                                                                                                                                                                                       
make[1]: Leaving directory '/mold/mimalloc/out/release'                                                                                                                                                                                       

make: Leaving directory '/mold'
pacak commented 3 years ago

I suspect missing libdbb-dev in the docker file.

rui314 commented 3 years ago

Can you check out https://github.com/rui314/mold.git again into a fresh directory and try again?

pacak commented 3 years ago

Seems to work. Interesting, make clean wasn't enough. Sorry for the noise.

pacak commented 3 years ago

README still asks to install libtbb-dev btw.

rui314 commented 3 years ago

oneTBB used to be a directory that make created, but it is now a subdirectory checked in to the repo. I think by default git doesn't override existing directories from the one checked out from repo. I think that's why it didn't work.