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

Documentation desired on Linux build system requirements #381

Open
SignumTemporis opened this issue Oct 17, 2024 · 4 comments
Open

Documentation desired on Linux build system requirements #381

SignumTemporis opened this issue Oct 17, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation p3

Comments

@SignumTemporis
Copy link

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
Copy link
Author

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?

@johnwbyrd
Copy link
Member

I don't see in our documentation where we teach coders how to set up a development system. I'm not sure that information belongs in the SDK, though I am willing to listen to argument regarding this point.

@johnwbyrd johnwbyrd changed the title Development procedure doesn't work Documentation desired on Linux build system requirements Oct 22, 2024
@johnwbyrd johnwbyrd added documentation Improvements or additions to documentation p3 labels Oct 22, 2024
@mysterymath
Copy link
Member

Generally agree w @johnwbyrd. If we had detailed steps about how to set up a build environment on e.g. Debian, then from what I've seen it's customary to include build-essentials. But we do presently leave it to developers to establish a working C/C++ development environment with CMake on their system; there's a quite great variety of ways to do that.

@SignumTemporis
Copy link
Author

I don't know how MOS llvm is organized in details. Reading Development procedure I assumed that MOS llvm / SDK is somehow self-sufficient to build itself.
This was my mistake and the root cause of the issue.

Now I know, that I need make, cmake, ninja and a working C/C++ (but other than MOS llvm itself :-).

My idea was to add maybe a simple tip to the documentation (a few words like above and platform agnostic) so that others can avoid the trap I fell into.

I fully agree that it's not the place to teach how to setup a C/C++ environment nor to explain how it can differ between possible platforms.

BTW, in case of Ubuntu build-essential provides such "working C/C++ dev env". It seems that the bare minimum is gcc and g++ packages (and their dependencies).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation p3
Projects
None yet
Development

No branches or pull requests

3 participants