Skip to content

WIP: building llvmlibc via fullbuild mode #52

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions llvm-project/Dockerfile.libc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM docker.io/alpine:edge as source
RUN wget --no-clobber \
https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-project-17.0.6.src.tar.xz

FROM docker.io/alpine:edge AS stage_one

COPY --from=source llvm-project-17.0.6.src.tar.xz /
RUN tar xf llvm-project-17.0.6.src.tar.xz && \
mv llvm-project-17.0.6.src llvm-project

RUN apk add cmake ninja clang python3 lld

COPY libc.cmake llvm-project/.
ARG LLVM_BUILD_DIR=llvm-project/llvm/build

RUN apk add linux-headers

RUN cmake \
-B ${LLVM_BUILD_DIR} \
-C llvm-project/libc.cmake \
-S llvm-project/llvm \
-G Ninja
7 changes: 6 additions & 1 deletion llvm-project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IMAGE ?= ghcr.io/clangbuiltlinux/llvm-project

dotfiles: stage2.svg stage1.svg

.PHONY: clang epoch1 epoch2 epoch3
.PHONY: clang epoch1 epoch2 epoch3 libc

# Argument 1: epoch# (e.g., epoch1; should match the suffix of the Dockerfile)
# Argument 2: Tag (e.g., ghcr.io/clangbuiltlinux/llvm-project:stage2-x86_64)
Expand All @@ -35,5 +35,10 @@ clang: epoch3
$(DOCKER) create --name llvm-project $(IMAGE):stage3-$(HOST_ARCH)
$(DOCKER) cp llvm-project:/usr/local/bin/clang-14 clang

libc:
$(DOCKER) rm libc || true
# $(DOCKER) create --name libc libc-$(HOST_ARCH)
$(DOCKER) build --file Dockerfile.libc . --tag libc

test: epoch3
bash ../ci/test-clang.sh $(IMAGE):stage3-$(HOST_ARCH)
17 changes: 17 additions & 0 deletions llvm-project/libc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use Alpine's clang and clang++ from their clang package as the stage0
# compilers.
set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE FILEPATH "")
set(CMAKE_C_COMPILER "/usr/bin/clang" CACHE FILEPATH "")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")

# Use Alpine's lld as the stage0 linker to link everything.
set(LLVM_ENABLE_LLD ON CACHE BOOL "")

# TODO: why does clang need to be enabled?
set(LLVM_ENABLE_PROJECTS "clang;compiler-rt;libc;" CACHE STRING "")

set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
set(LLVM_LIBC_INCLUDE_SCUDO ON CACHE BOOL "")
set(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC ON CACHE BOOL "")
set(COMPILER_RT_BUILD_GWP_ASAN OFF CACHE BOOL "")
set(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED OFF CACHE BOOL "")