llvm-mos / llvm-mos-sdk

SDK for developing with the llvm-mos compiler
https://www.llvm-mos.org
Other
271 stars 56 forks source link

Development procedure doesn't work #381

Open SignumTemporis opened 1 day ago

SignumTemporis commented 1 day ago

I'm trying to apply a patch to SDK. However, when I follow Development procedure I get an error.

What can be wrong?

The procedure (as Dockerfile):

FROM ubuntu:22.04

ARG SDK_VERSION=20.2.0
ARG SDK_INSTALL_PREFIX=/opt

RUN apt-get update
RUN apt-get install -y git wget xz-utils
RUN apt-get install -y make cmake ninja-build

WORKDIR /tmp

RUN wget https://github.com/llvm-mos/llvm-mos-sdk/releases/download/v${SDK_VERSION}/llvm-mos-linux.tar.xz
RUN tar --no-same-owner -C ${SDK_INSTALL_PREFIX} -xJf llvm-mos-linux.tar.xz

ENV PATH=${SDK_INSTALL_PREFIX}/llvm-mos/bin:${PATH}

RUN git clone --depth 1 https://github.com/llvm-mos/llvm-mos-sdk.git
RUN mkdir llvm-mos-sdk/build
WORKDIR /tmp/llvm-mos-sdk/build
RUN cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=${SDK_INSTALL_PREFIX}/llvm-mos/ ..
RUN ninja install
WORKDIR /tmp

The procedure fails in cmake step:

 > [11/13] RUN cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=/opt/llvm-mos/ ..:
0.416 -- No build type selected, default to MinSizeRel
0.528 -- The C compiler identification is GNU 11.4.0
0.687 -- The CXX compiler identification is Clang 20.0.0
0.706 -- The ASM compiler identification is GNU
0.710 -- Found assembler: /usr/bin/cc
0.726 -- Detecting C compiler ABI info
0.827 -- Detecting C compiler ABI info - done
0.845 -- Check for working C compiler: /usr/bin/cc - skipped
0.846 -- Detecting C compile features
0.847 -- Detecting C compile features - done
0.858 -- Detecting CXX compiler ABI info
0.963 -- Detecting CXX compiler ABI info - failed
0.963 -- Check for working CXX compiler: /opt/llvm-mos/bin/clang++
1.064 -- Check for working CXX compiler: /opt/llvm-mos/bin/clang++ - broken
1.064 CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
1.064   The C++ compiler
1.064 
1.064     "/opt/llvm-mos/bin/clang++"
1.064 
1.064   is not able to compile a simple test program.
1.064 
1.064   It fails with the following output:
1.064 
1.064     Change Dir: /tmp/llvm-mos-sdk/build/CMakeFiles/CMakeTmp
1.064     
1.064     Run Build Command(s):/usr/bin/ninja cmTC_4ff06 && [1/2] Building CXX object CMakeFiles/cmTC_4ff06.dir/testCXXCompiler.cxx.o
1.064     [2/2] Linking CXX executable cmTC_4ff06
1.064     FAILED: cmTC_4ff06 
1.064     : && /opt/llvm-mos/bin/clang++   CMakeFiles/cmTC_4ff06.dir/testCXXCompiler.cxx.o -o cmTC_4ff06   && :
1.064     ld.lld: error: unable to find library -l:crt0.o
1.064     ld.lld: error: unable to find library -lcrt0
1.064     ld.lld: error: unable to find library -lcrt
1.064     ld.lld: error: unable to find library -lc
1.064     ld.lld: error: cannot find linker script link.ld
1.064     clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
1.064     ninja: build stopped: subcommand failed.
1.064     
1.064 
1.064   CMake will not be able to correctly generate this project.
1.064 Call Stack (most recent call first):
1.064   CMakeLists.txt:9 (project)
1.064 
1.064 
1.066 -- Configuring incomplete, errors occurred!
1.066 See also "/tmp/llvm-mos-sdk/build/CMakeFiles/CMakeOutput.log".
1.066 See also "/tmp/llvm-mos-sdk/build/CMakeFiles/CMakeError.log".

Relates to: #378 issue, 4fc7b2d patch.

SignumTemporis commented 1 day ago

Adding build-essential package seems to solve the problem The change to the above Dockerfile which solves the issue is:

@@ -8 +8 @@ RUN apt-get install -y git wget xz-utils
-RUN apt-get install -y make cmake ninja-build
+RUN apt-get install -y build-essential make cmake ninja-build
@@ -15,2 +14,0 @@ RUN tar --no-same-owner -C ${SDK_INSTALL_PREFIX} -xJf llvm-mos-linux.tar.xz
-ENV PATH=${SDK_INSTALL_PREFIX}/llvm-mos/bin:${PATH}
-
@@ -22,0 +21,2 @@ WORKDIR /tmp
+
+ENV PATH=${SDK_INSTALL_PREFIX}/llvm-mos/bin:${PATH}

I haven't checked the minimal set of dependencies (e.g. build-essential includes dpkg-dev which doesn't seem to be required here).

Perhaps the Development procedure could be updated, so that it mentions more dependencies?