Skip to content

Commit 4d9fa39

Browse files
authored
Add linux_glibc_2_35 sysroot based on ubuntu22 and GCC12 (x86 64 only) (#118)
1 parent d8d8f49 commit 4d9fa39

File tree

10 files changed

+291
-417
lines changed

10 files changed

+291
-417
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,12 @@ Supported versions of LLVM are:
6969
* macOS aarch64 LLVM `18` / `20` - *In Development*
7070

7171
Available sysroots are:
72-
* Linux x86_64 `linux_glibc_2_27` / `linux_glibc_2_31`
73-
* Linux aarch64 `linux_glibc_2_27` / `linux_glibc_2_31`
7472

75-
Details about sysroots
76-
77-
| Name | GCC | GLIBC | C++ Standard | Used OS |
78-
|------------------|---|---|--------------|---------|
79-
| linux_glibc_2_27 | GCC 8 | 2.27 | C++17 | Ubuntu 18.04 |
80-
| linux_glibc_2_31 | GCC 10 | 2.31 | C++20 | Ubuntu 20.04 |
73+
| Name | Supported Arch. | GCC | GLIBC | C++ Standard | Used OS |
74+
|------------------|-----------------|--------|-------|-----------------------|--------------|
75+
| linux_glibc_2_27 | x86_64, aarch64 | GCC 8 | 2.27 | C++17 | Ubuntu 18.04 |
76+
| linux_glibc_2_31 | x86_64, aarch64 | GCC 10 | 2.31 | C++20 | Ubuntu 20.04 |
77+
| linux_glibc_2_35 | x86_64 | GCC 12 | 2.35 | C++23 partial support | Ubuntu 22.04 |
8178

8279
## How to run this project tests
8380
### CPU hermetic tests
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Create docker image from Dockerfile
2+
# docker build -t sysroot_ubuntu18_x86_64:latest -f ./sysroot_ubuntu18_x86_64.Dockerfile .
3+
4+
# Run docker image
5+
# docker run -it sysroot_ubuntu18_x86_64
6+
7+
# Copy needed directories from Docker image
8+
# docker cp <DOCKER IMG ID>:/usr .
9+
# docker cp <DOCKER IMG ID>:/lib .
10+
# docker cp <DOCKER IMG ID>:/lib64 .
11+
12+
# Fix invalid links
13+
14+
# Fix ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
15+
# cd lib64/
16+
# sudo rm ./ld-linux-x86-64.so.2
17+
# sudo ln -s ../lib/x86_64-linux-gnu/ld-2.27.so ./ld-linux-x86-64.so.2
18+
19+
# Fix libdl.so -> /lib/x86_64-linux-gnu/libdl.so.2
20+
# cd usr/lib/x86_64-linux-gnu
21+
# sudo rm ./libdl.so
22+
# sudo ln -s ../../../lib/x86_64-linux-gnu/libdl.so.2 ./libdl.so
23+
24+
# Fix libmvec.so -> /lib/x86_64-linux-gnu/libmvec.so.1
25+
# cd usr/lib/x86_64-linux-gnu/
26+
# rm ./libmvec.so
27+
# sudo ln -s ../../../lib/x86_64-linux-gnu/libmvec.so.1 ./libmvec.so
28+
29+
FROM ubuntu:18.04
30+
31+
RUN apt-get update
32+
RUN apt-get -y install \
33+
build-essential \
34+
gcc-8 g++-8 \
35+
libomp-dev
36+
37+
RUN rm -rf /usr/include/c++/7
38+
RUN rm -rf /usr/include/c++/7.5.0
39+
RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7
40+
RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7.5.0
41+
42+
WORKDIR /root
43+
44+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Create docker image from Dockerfile
2+
# docker build -t sysroot_ubuntu22-x86_64:latest -f ./sysroot_ubuntu22-x86_64.Dockerfile .
3+
4+
# Run docker image
5+
# docker run -it sysroot_ubuntu22-x86_64
6+
7+
# Copy needed directories from Docker image
8+
# docker cp <DOCKER IMG ID>:/usr .
9+
# docker cp <DOCKER IMG ID>:/lib .
10+
# docker cp <DOCKER IMG ID>:/lib64 .
11+
12+
# Fix invalid links
13+
14+
# Fix ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
15+
# cd lib64/
16+
# sudo rm ./ld-linux-x86-64.so.2
17+
# sudo ln -s ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ./ld-linux-x86-64.so.2
18+
19+
# Fix libmvec.so -> /lib/x86_64-linux-gnu/libmvec.so.1
20+
# cd usr/lib/x86_64-linux-gnu/
21+
# rm ./libmvec.so
22+
# sudo ln -s ../../../lib/x86_64-linux-gnu/libmvec.so.1 ./libmvec.so
23+
24+
# Add links
25+
# cd lib/x86_64-linux-gnu/
26+
# sudo ln -s ./libpthread.so.0 ./libpthread.so
27+
# cd usr/lib/x86_64-linux-gnu/
28+
# sudo ln -s ./libdl.so.2 ./libdl.so
29+
30+
FROM ubuntu:22.04
31+
32+
RUN apt-get update
33+
RUN apt-get -y install \
34+
build-essential \
35+
gcc-12 g++-12 \
36+
libomp-dev
37+
38+
RUN rm -rf /usr/include/c++/11
39+
RUN rm -rf /usr/include/x86_64-linux-gnu/c++/11
40+
RUN rm -rf /usr/lib/gcc/x86_64-linux-gnu/11
41+
42+
WORKDIR /root
43+
44+
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
16+
load(
17+
"@rules_ml_toolchain//third_party/rules_cc_toolchain:sysroot.bzl",
18+
"sysroot_package",
19+
)
20+
load(
21+
"@rules_ml_toolchain//third_party/rules_cc_toolchain/features:cc_toolchain_import.bzl",
22+
"cc_toolchain_import",
23+
)
24+
25+
sysroot_package(
26+
name = "sysroot",
27+
visibility = ["//visibility:public"],
28+
)
29+
30+
GCC_VERSION = 12
31+
GLIBC_VERSION = "2.35"
32+
33+
# Details about C RunTime (CRT) objects:
34+
# https://docs.oracle.com/cd/E88353_01/html/E37853/crt1.o-7.html
35+
# https://dev.gentoo.org/~vapier/crt.txt
36+
CRT_OBJECTS = [
37+
"crti",
38+
"crtn",
39+
# Use PIC Scrt1.o instead of crt1.o to keep PIC code from segfaulting.
40+
"Scrt1",
41+
]
42+
43+
[
44+
cc_toolchain_import(
45+
name = obj,
46+
static_library = "usr/lib/x86_64-linux-gnu/%s.o" % obj,
47+
)
48+
for obj in CRT_OBJECTS
49+
]
50+
51+
cc_toolchain_import(
52+
name = "startup_libs",
53+
visibility = ["//visibility:public"],
54+
deps = [":" + obj for obj in CRT_OBJECTS],
55+
)
56+
57+
cc_toolchain_import(
58+
name = "includes_c",
59+
hdrs = glob([
60+
"usr/include/c++/{gcc_version}/**".format(gcc_version = GCC_VERSION),
61+
"usr/include/x86_64-linux-gnu/c++/{gcc_version}/*/**".format(gcc_version = GCC_VERSION),
62+
"usr/include/c++/{gcc_version}/experimental/**".format(gcc_version = GCC_VERSION),
63+
]),
64+
includes = [
65+
"usr/include/c++/{gcc_version}".format(gcc_version = GCC_VERSION),
66+
"usr/include/x86_64-linux-gnu/c++/{gcc_version}".format(gcc_version = GCC_VERSION),
67+
"usr/include/c++/{gcc_version}/backward".format(gcc_version = GCC_VERSION),
68+
"usr/include/c++/{gcc_version}/experimental".format(gcc_version = GCC_VERSION),
69+
],
70+
visibility = ["//visibility:public"],
71+
)
72+
73+
cc_toolchain_import(
74+
name = "includes_system",
75+
hdrs = glob([
76+
"usr/local/include/**",
77+
"usr/include/x86_64-linux-gnu/**",
78+
"usr/include/**",
79+
]),
80+
includes = [
81+
"usr/local/include",
82+
"usr/include/x86_64-linux-gnu",
83+
"usr/include",
84+
],
85+
visibility = ["//visibility:public"],
86+
)
87+
88+
cc_toolchain_import(
89+
name = "gcc",
90+
additional_libs = [
91+
"lib/x86_64-linux-gnu/libgcc_s.so.1",
92+
"usr/lib/gcc/x86_64-linux-gnu/{gcc_version}/libgcc_eh.a".format(gcc_version = GCC_VERSION),
93+
],
94+
shared_library = "usr/lib/gcc/x86_64-linux-gnu/{gcc_version}/libgcc_s.so".format(gcc_version = GCC_VERSION),
95+
static_library = "usr/lib/gcc/x86_64-linux-gnu/{gcc_version}/libgcc.a".format(gcc_version = GCC_VERSION),
96+
visibility = ["//visibility:public"],
97+
)
98+
99+
cc_toolchain_import(
100+
name = "stdc++",
101+
additional_libs = [
102+
"usr/lib/x86_64-linux-gnu/libstdc++.so.6",
103+
"usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30",
104+
],
105+
shared_library = "usr/lib/gcc/x86_64-linux-gnu/{gcc_version}/libstdc++.so".format(gcc_version = GCC_VERSION),
106+
static_library = "usr/lib/gcc/x86_64-linux-gnu/{gcc_version}/libstdc++.a".format(gcc_version = GCC_VERSION),
107+
visibility = ["//visibility:public"],
108+
)
109+
110+
cc_toolchain_import(
111+
name = "dynamic_linker",
112+
additional_libs = [
113+
"lib64/ld-linux-x86-64.so.2",
114+
"lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",
115+
"usr/lib/x86_64-linux-gnu/libdl.so.2",
116+
],
117+
shared_library = "usr/lib/x86_64-linux-gnu/libdl.so",
118+
static_library = "usr/lib/x86_64-linux-gnu/libdl.a",
119+
deps = [":libc"],
120+
)
121+
122+
cc_toolchain_import(
123+
name = "math",
124+
additional_libs = [
125+
"lib/x86_64-linux-gnu/libm.so.6",
126+
"lib/x86_64-linux-gnu/libmvec.so.1",
127+
"usr/lib/x86_64-linux-gnu/libm-{glibc_version}.a".format(glibc_version = GLIBC_VERSION),
128+
"usr/lib/x86_64-linux-gnu/libmvec.so",
129+
"usr/lib/x86_64-linux-gnu/libmvec.a",
130+
],
131+
shared_library = "usr/lib/x86_64-linux-gnu/libm.so",
132+
visibility = ["//visibility:public"],
133+
)
134+
135+
cc_toolchain_import(
136+
name = "pthread",
137+
additional_libs = [
138+
"usr/lib/x86_64-linux-gnu/libpthread.so.0",
139+
],
140+
shared_library = "usr/lib/x86_64-linux-gnu/libpthread.so",
141+
static_library = "usr/lib/x86_64-linux-gnu/libpthread.a",
142+
visibility = ["//visibility:public"],
143+
deps = [
144+
":libc",
145+
],
146+
)
147+
148+
cc_toolchain_import(
149+
name = "rt",
150+
additional_libs = [
151+
"usr/lib/x86_64-linux-gnu/librt.so.1",
152+
"usr/lib/x86_64-linux-gnu/librt.a",
153+
],
154+
visibility = ["//visibility:private"],
155+
)
156+
157+
cc_toolchain_import(
158+
name = "libc",
159+
additional_libs = [
160+
"lib/x86_64-linux-gnu/libc.so.6",
161+
"usr/lib/x86_64-linux-gnu/libc_nonshared.a",
162+
],
163+
shared_library = "usr/lib/x86_64-linux-gnu/libc.so",
164+
static_library = "usr/lib/x86_64-linux-gnu/libc.a",
165+
visibility = ["//visibility:public"],
166+
deps = [
167+
":gcc",
168+
":math",
169+
":stdc++",
170+
":rt",
171+
],
172+
)
173+
174+
# This is a group of all the system libraries we need. The actual glibc library is split
175+
# out to fix link ordering problems that cause false undefined symbol positives.
176+
cc_toolchain_import(
177+
name = "glibc",
178+
visibility = ["//visibility:public"],
179+
deps = [
180+
":dynamic_linker",
181+
":libc",
182+
],
183+
)

cc/cuda/tools.bzl

Lines changed: 0 additions & 24 deletions
This file was deleted.

cc/cuda/wrappers/BUILD

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)