拥抱clang, cpp 23我来了
This commit is contained in:
@@ -1,29 +1,33 @@
|
|||||||
FROM ubuntu:24.04 # 改用 Ubuntu 24.04,自带 GCC 13
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
# 设置非root用户
|
# 1. 安装LLVM/Clang 17+工具链(Ubuntu 24.04官方源已包含)
|
||||||
RUN useradd -m -s /bin/bash builder
|
|
||||||
|
|
||||||
# 1. 安装基础工具(Ubuntu 24.04 已有 GCC 13)
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
wget tar git curl ca-certificates \
|
wget tar git curl ca-certificates \
|
||||||
build-essential \
|
build-essential \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
clang-17 lld-17 libc++-17-dev libc++abi-17-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* && \
|
||||||
|
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100 && \
|
||||||
|
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100 && \
|
||||||
|
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-17 100
|
||||||
|
|
||||||
# 2. 切换到builder用户安装xmake
|
# 2. 设置非root用户
|
||||||
|
RUN useradd -m -s /bin/bash builder
|
||||||
|
|
||||||
|
# 3. 切换到builder用户安装xmake
|
||||||
USER builder
|
USER builder
|
||||||
WORKDIR /home/builder
|
WORKDIR /home/builder
|
||||||
|
|
||||||
# 下载并安装xmake
|
|
||||||
RUN wget -O xmake https://git.fig-lang.cn/PuqiAR/xmake-binary-copy/raw/commit/989d1f2dabb0bc8d5981a5f900c2cf7c2ac78ee4/xmake-bundle-v3.0.5.linux.x86_64 && \
|
RUN wget -O xmake https://git.fig-lang.cn/PuqiAR/xmake-binary-copy/raw/commit/989d1f2dabb0bc8d5981a5f900c2cf7c2ac78ee4/xmake-bundle-v3.0.5.linux.x86_64 && \
|
||||||
chmod +x xmake && \
|
chmod +x xmake && \
|
||||||
./xmake --version 2>&1 | head -1
|
./xmake --version 2>&1 | head -1
|
||||||
|
|
||||||
|
# 4. 切回root,将xmake安装到系统路径
|
||||||
USER root
|
USER root
|
||||||
RUN cp /home/builder/xmake /usr/local/bin/xmake && \
|
RUN cp /home/builder/xmake /usr/local/bin/xmake && \
|
||||||
chmod +x /usr/local/bin/xmake
|
chmod +x /usr/local/bin/xmake
|
||||||
|
|
||||||
# 3. 验证编译器版本
|
# 5. 验证环境
|
||||||
RUN gcc --version && g++ --version
|
RUN clang++ --version && xmake --version
|
||||||
|
|
||||||
USER builder
|
USER builder
|
||||||
@@ -8,8 +8,9 @@ target("Fig")
|
|||||||
set_languages("c++23")
|
set_languages("c++23")
|
||||||
|
|
||||||
if is_plat("linux") then
|
if is_plat("linux") then
|
||||||
add_cxxflags("-static-libstdc++", "-static-libgcc")
|
set_toolchains("clang")
|
||||||
add_ldflags("-static")
|
add_cxxflags("-stdlib=libc++")
|
||||||
|
add_ldflags("-stdlib=libc++")
|
||||||
elseif is_plat("mingw") then
|
elseif is_plat("mingw") then
|
||||||
add_cxxflags("-static")
|
add_cxxflags("-static")
|
||||||
add_ldflags("-static")
|
add_ldflags("-static")
|
||||||
|
|||||||
Reference in New Issue
Block a user