diff --git a/cc/config/sysroot-dockerfiles/sysroot_ubuntu18_x86_64.Dockerfile b/cc/config/sysroot-dockerfiles/sysroot_ubuntu18_x86_64.Dockerfile deleted file mode 100644 index 38307466..00000000 --- a/cc/config/sysroot-dockerfiles/sysroot_ubuntu18_x86_64.Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# Create docker image from Dockerfile -# docker build -t sysroot_ubuntu18_x86_64:latest -f ./sysroot_ubuntu18_x86_64.Dockerfile . - -# Run docker image -# docker run -it sysroot_ubuntu18_x86_64 - -# Copy needed directories from Docker image -# docker cp :/usr . -# docker cp :/lib . -# docker cp :/lib64 . - -# Fix invalid links - -# Fix ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -# cd lib64/ -# sudo rm ./ld-linux-x86-64.so.2 -# sudo ln -s ../lib/x86_64-linux-gnu/ld-2.27.so ./ld-linux-x86-64.so.2 - -# Fix libdl.so -> /lib/x86_64-linux-gnu/libdl.so.2 -# cd usr/lib/x86_64-linux-gnu -# sudo rm ./libdl.so -# sudo ln -s ../../../lib/x86_64-linux-gnu/libdl.so.2 ./libdl.so - -# Fix libmvec.so -> /lib/x86_64-linux-gnu/libmvec.so.1 -# cd usr/lib/x86_64-linux-gnu/ -# rm ./libmvec.so -# sudo ln -s ../../../lib/x86_64-linux-gnu/libmvec.so.1 ./libmvec.so - -FROM ubuntu:18.04 - -RUN apt-get update -RUN apt-get -y install \ - build-essential \ - gcc-8 g++-8 \ - libomp-dev - -RUN rm -rf /usr/include/c++/7 -RUN rm -rf /usr/include/c++/7.5.0 -RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7 -RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7.5.0 - -WORKDIR /root - - diff --git a/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/BUILD.bazel b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/Dockerfile b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/Dockerfile new file mode 100644 index 00000000..bbaae395 --- /dev/null +++ b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/Dockerfile @@ -0,0 +1,67 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +FROM arm64v8/ubuntu:bionic + +RUN apt-get update && apt-get -y install \ + build-essential \ + gcc-8 g++-8 \ + libomp-dev + +RUN rm -rf /usr/include/c++/7.5.0 +RUN rm -rf /usr/include/c++/7 +RUN rm -rf /usr/include/aarch64-linux-gnu/c++/7.5.0 +RUN rm -rf /usr/include/aarch64-linux-gnu/c++/7 +RUN rm -rf /usr/lib/gcc/aarch64-linux-gnu/7 + +# Replace absulte links by relative in /usr/lib/aarch64-linux-gnu/ directory +WORKDIR /usr/lib/aarch64-linux-gnu + +# /usr/lib/aarch64-linux-gnu/libBrokenLocale.so -> /lib/aarch64-linux-gnu/libBrokenLocale.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libBrokenLocale.so.1 ./libBrokenLocale.so +# /usr/lib/aarch64-linux-gnu/libanl.so -> /lib/aarch64-linux-gnu/libanl.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libanl.so.1 ./libanl.so +# /usr/lib/aarch64-linux-gnu/libcidn.so -> /lib/aarch64-linux-gnu/libcidn.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libcidn.so.1 ./libcidn.so +# /usr/lib/aarch64-linux-gnu/libcrypt.so -> /lib/aarch64-linux-gnu/libcrypt.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libcrypt.so.1 ./libcrypt.so +# /usr/lib/aarch64-linux-gnu/libdl.so -> /lib/aarch64-linux-gnu/libdl.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libdl.so.2 ./libdl.so +# /usr/lib/aarch64-linux-gnu/libm.so -> /lib/aarch64-linux-gnu/libm.so.6 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libm.so.6 ./libm.so +# /usr/lib/aarch64-linux-gnu/libnsl.so -> /lib/aarch64-linux-gnu/libnsl.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnsl.so.1 ./libnsl.so +# /usr/lib/aarch64-linux-gnu/libnss_compat.so -> /lib/aarch64-linux-gnu/libnss_compat.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_compat.so.2 ./libnss_compat.so +# /usr/lib/aarch64-linux-gnu/libnss_dns.so -> /lib/aarch64-linux-gnu/libnss_dns.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_dns.so.2 ./libnss_dns.so +# /usr/lib/aarch64-linux-gnu/libnss_files.so -> /lib/aarch64-linux-gnu/libnss_files.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_files.so.2 ./libnss_files.so +# /usr/lib/aarch64-linux-gnu/libnss_hesiod.so -> /lib/aarch64-linux-gnu/libnss_hesiod.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_hesiod.so.2 ./libnss_hesiod.so +# /usr/lib/aarch64-linux-gnu/libnss_nis.so -> /lib/aarch64-linux-gnu/libnss_nis.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_nis.so.2 ./libnss_nis.so +# /usr/lib/aarch64-linux-gnu/libnss_nisplus.so -> /lib/aarch64-linux-gnu/libnss_nisplus.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libnss_nisplus.so.2 ./libnss_nisplus.so +# /usr/lib/aarch64-linux-gnu/libresolv.so -> /lib/aarch64-linux-gnu/libresolv.so.2 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libresolv.so.2 ./libresolv.so +# /usr/lib/aarch64-linux-gnu/librt.so -> /lib/aarch64-linux-gnu/librt.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/librt.so.1 ./librt.so +# /usr/lib/aarch64-linux-gnu/libthread_db.so -> /lib/aarch64-linux-gnu/libthread_db.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libthread_db.so.1 ./libthread_db.so +# /usr/lib/aarch64-linux-gnu/libutil.so -> /lib/aarch64-linux-gnu/libutil.so.1 +RUN ln -sfn ../../../lib/aarch64-linux-gnu/libutil.so.1 ./libutil.so + +WORKDIR /root diff --git a/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/create-sysroot.sh b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/create-sysroot.sh new file mode 100644 index 00000000..3417c5fe --- /dev/null +++ b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/create-sysroot.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " +fi + +SYSROOT="$(basename "$(pwd)")" +CONTAINER=$(echo "$SYSROOT" | sed -E 's/.*ubuntu([0-9]+).*/u\1sysroot/') + +echo "Please enter sysroot version (default: 0.1.0):" +read VERSION +if [ -z "$VERSION" ]; then + VERSION="0.1.0" +fi + +ARCH_NAME=$SYSROOT-$VERSION + +# Remove old files and image +rm -rf /tmp/$ARCH_NAME +docker rm -f $CONTAINER +docker rmi -f $ARCH_NAME:latest + +# Create docker image from Dockerfile +echo -e "\nBuilding docker image $ARCH_NAME:latest" +docker build -t $ARCH_NAME:latest . + +# Run docker image +echo -e "\nRunning docker image $ARCH_NAME:latest, container name $CONTAINER" +docker run -d --name $CONTAINER $ARCH_NAME:latest bash -c "sleep 20" + +echo -e "\nCopying files from docker container..." +mkdir /tmp/$ARCH_NAME + +# Copy needed directories from Docker image +docker cp $CONTAINER:/lib /tmp/$ARCH_NAME/ +docker cp $CONTAINER:/usr /tmp/$ARCH_NAME/ +# Remove not used directories +rm -rf /tmp/$ARCH_NAME/lib/cpp +rm -rf /tmp/$ARCH_NAME/usr/bin +rm -rf /tmp/$ARCH_NAME/usr/games +rm -rf /tmp/$ARCH_NAME/usr/sbin +rm -rf /tmp/$ARCH_NAME/usr/share +rm -rf /tmp/$ARCH_NAME/usr/src + +echo -e "\nCreating /tmp/$ARCH_NAME.tar.xz archive..." +XZ_OPT="-T8" +tar -cJf /tmp/$ARCH_NAME.tar.xz -C /tmp/ $ARCH_NAME \ No newline at end of file diff --git a/cc/config/sysroot_ubuntu18_aarch64.BUILD b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/sysroot_aarch64_ubuntu18.BUILD similarity index 88% rename from cc/config/sysroot_ubuntu18_aarch64.BUILD rename to cc/config/sysroot_aarch64_ubuntu18_gcc8.4/sysroot_aarch64_ubuntu18.BUILD index f99ab379..b602d74a 100644 --- a/cc/config/sysroot_ubuntu18_aarch64.BUILD +++ b/cc/config/sysroot_aarch64_ubuntu18_gcc8.4/sysroot_aarch64_ubuntu18.BUILD @@ -30,6 +30,9 @@ sysroot_package( GCC_VERSION = 8 GLIBC_VERSION = "2.27" +# Details about C RunTime (CRT) objects: +# https://docs.oracle.com/cd/E88353_01/html/E37853/crt1.o-7.html +# https://dev.gentoo.org/~vapier/crt.txt CRT_OBJECTS = [ "crti", "crtn", @@ -88,7 +91,6 @@ cc_toolchain_import( "lib/aarch64-linux-gnu/libgcc_s.so.1", "usr/lib/gcc/aarch64-linux-gnu/{gcc_version}/libgcc_eh.a".format(gcc_version = GCC_VERSION), ], - runtime_path = "/usr/lib/aarch64-linux-gnu", shared_library = "usr/lib/gcc/aarch64-linux-gnu/{gcc_version}/libgcc_s.so".format(gcc_version = GCC_VERSION), static_library = "usr/lib/gcc/aarch64-linux-gnu/{gcc_version}/libgcc.a".format(gcc_version = GCC_VERSION), visibility = ["//visibility:public"], @@ -116,10 +118,10 @@ cc_toolchain_import( cc_toolchain_import( name = "dynamic_linker", additional_libs = [ + "lib/ld-linux-aarch64.so.1", "lib/aarch64-linux-gnu/ld-linux-aarch64.so.1", "lib/aarch64-linux-gnu/ld-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), ], - runtime_path = "/lib64", shared_library = "usr/lib/aarch64-linux-gnu/libdl.so", static_library = "usr/lib/aarch64-linux-gnu/libdl.a", deps = [":libc"], @@ -153,9 +155,9 @@ cc_toolchain_import( additional_libs = [ "lib/aarch64-linux-gnu/librt-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), "lib/aarch64-linux-gnu/librt.so.1", - "usr/lib/aarch64-linux-gnu/librt.so", - "usr/lib/aarch64-linux-gnu/librt.a", ], + shared_library = "usr/lib/aarch64-linux-gnu/librt.so", + static_library = "usr/lib/aarch64-linux-gnu/librt.a", visibility = ["//visibility:private"], ) @@ -163,15 +165,11 @@ cc_toolchain_import( name = "libc", additional_libs = [ "lib/aarch64-linux-gnu/libc.so.6", + "lib/aarch64-linux-gnu/libc-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), "usr/lib/aarch64-linux-gnu/libc_nonshared.a", ], - runtime_path = "/usr/lib/gcc/aarch64-linux-gnu/{gcc_version}".format(gcc_version = GCC_VERSION), shared_library = "usr/lib/aarch64-linux-gnu/libc.so", static_library = "usr/lib/aarch64-linux-gnu/libc.a", - #target_compatible_with = select({ - # "@platforms//os:linux": ["@platforms//cpu:aarch64"], - # "//conditions:default": ["@platforms//:incompatible"], - #}), visibility = ["//visibility:public"], deps = [ ":gcc", @@ -182,14 +180,25 @@ cc_toolchain_import( ], ) -# This is a group of all the system libraries we need. The actual glibc library is split -# out to fix link ordering problems that cause false undefined symbol positives. +# Application Programming Interface (API) for shared-memory parallel programming. cc_toolchain_import( - name = "glibc", - runtime_path = "/lib/aarch64-linux-gnu", + name = "openmp", + additional_libs = glob([ + "usr/lib/aarch64-linux-gnu/libgomp*", + "usr/lib/aarch64-linux-gnu/libomp*", + ]), visibility = ["//visibility:public"], +) + +# This is a group of all the system libraries we need. The actual essential libraries is split +# out to fix link ordering problems that cause false undefined symbol positives. +cc_toolchain_import( + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_darwin_aarch64.BUILD b/cc/config/sysroot_darwin_aarch64.BUILD index ae220e56..02a1471e 100644 --- a/cc/config/sysroot_darwin_aarch64.BUILD +++ b/cc/config/sysroot_darwin_aarch64.BUILD @@ -133,13 +133,8 @@ cc_toolchain_import( # This is a group of all the system libraries we need. The actual glibc library is split # out to fix link ordering problems that cause false undefined symbol positives. cc_toolchain_import( - name = "glibc", + name = "libs", #runtime_path = "usr/lib", - #target_compatible_with = select({ - # "@platforms//os:macos": ["@platforms//cpu:aarch64"], - # "//conditions:default": ["@platforms//:incompatible"], - #}), - visibility = ["//visibility:public"], deps = [ ":system", ":libm", @@ -147,4 +142,5 @@ cc_toolchain_import( ":objc", ":core_foundation", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_ubuntu18_x86_64_gcc9.BUILD b/cc/config/sysroot_ubuntu18_x86_64_gcc9.BUILD index de1e3afe..1f2a3b5e 100644 --- a/cc/config/sysroot_ubuntu18_x86_64_gcc9.BUILD +++ b/cc/config/sysroot_ubuntu18_x86_64_gcc9.BUILD @@ -169,22 +169,24 @@ cc_toolchain_import( ], shared_library = "usr/lib/x86_64-linux-gnu/libc.so", static_library = "usr/lib/x86_64-linux-gnu/libc.a", - visibility = ["//visibility:public"], deps = [ ":gcc", ":math", ":stdc++", ":rt", ], + visibility = ["//visibility:public"], ) -# This is a group of all the system libraries we need. The actual glibc library is split +# This is a group of all the system libraries we need. The actual essential libraries is split # out to fix link ordering problems that cause false undefined symbol positives. cc_toolchain_import( - name = "glibc", - visibility = ["//visibility:public"], + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_ubuntu20_aarch64_gcc10.BUILD b/cc/config/sysroot_ubuntu20_aarch64_gcc10.BUILD index 39eb74d6..98c861c3 100644 --- a/cc/config/sysroot_ubuntu20_aarch64_gcc10.BUILD +++ b/cc/config/sysroot_ubuntu20_aarch64_gcc10.BUILD @@ -163,23 +163,24 @@ cc_toolchain_import( # "@platforms//os:linux": ["@platforms//cpu:aarch64"], # "//conditions:default": ["@platforms//:incompatible"], #}), - visibility = ["//visibility:public"], deps = [ ":gcc", ":math", ":stdc++", ":rt", ], + visibility = ["//visibility:public"], ) -# This is a group of all the system libraries we need. The actual glibc library is split +# This is a group of all the system libraries we need. The actual essential libraries is split # out to fix link ordering problems that cause false undefined symbol positives. cc_toolchain_import( - name = "glibc", - runtime_path = "/lib/aarch64-linux-gnu", - visibility = ["//visibility:public"], + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_ubuntu20_x86_64_gcc10.BUILD b/cc/config/sysroot_ubuntu20_x86_64_gcc10.BUILD index 41fa411b..801a8ea7 100644 --- a/cc/config/sysroot_ubuntu20_x86_64_gcc10.BUILD +++ b/cc/config/sysroot_ubuntu20_x86_64_gcc10.BUILD @@ -167,22 +167,34 @@ cc_toolchain_import( ], shared_library = "usr/lib/x86_64-linux-gnu/libc.so", static_library = "usr/lib/x86_64-linux-gnu/libc.a", - visibility = ["//visibility:public"], deps = [ ":gcc", ":math", ":stdc++", ":rt", ], + visibility = ["//visibility:public"], ) -# This is a group of all the system libraries we need. The actual glibc library is split -# out to fix link ordering problems that cause false undefined symbol positives. +# Application Programming Interface (API) for shared-memory parallel programming. cc_toolchain_import( - name = "glibc", + name = "openmp", + additional_libs = glob([ + "usr/lib/x86_64-linux-gnu/libgomp*", + "usr/lib/x86_64-linux-gnu/libomp*", + ]), visibility = ["//visibility:public"], +) + +# This is a group of all the system libraries we need. The actual essential libraries is split +# out to fix link ordering problems that cause false undefined symbol positives. +cc_toolchain_import( + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_ubuntu22_x86_64_gcc12.BUILD b/cc/config/sysroot_ubuntu22_x86_64_gcc12.BUILD index 245bce0f..4ce3ba6c 100644 --- a/cc/config/sysroot_ubuntu22_x86_64_gcc12.BUILD +++ b/cc/config/sysroot_ubuntu22_x86_64_gcc12.BUILD @@ -162,22 +162,34 @@ cc_toolchain_import( ], shared_library = "usr/lib/x86_64-linux-gnu/libc.so", static_library = "usr/lib/x86_64-linux-gnu/libc.a", - visibility = ["//visibility:public"], deps = [ ":gcc", ":math", ":stdc++", ":rt", ], + visibility = ["//visibility:public"], ) -# This is a group of all the system libraries we need. The actual glibc library is split -# out to fix link ordering problems that cause false undefined symbol positives. +# Application Programming Interface (API) for shared-memory parallel programming. cc_toolchain_import( - name = "glibc", + name = "openmp", + additional_libs = glob([ + "usr/lib/x86_64-linux-gnu/libgomp*", + "usr/lib/x86_64-linux-gnu/libomp*", + ]), visibility = ["//visibility:public"], +) + +# This is a group of all the system libraries we need. The actual essential libraries is split +# out to fix link ordering problems that cause false undefined symbol positives. +cc_toolchain_import( + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/BUILD.bazel b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/Dockerfile b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/Dockerfile new file mode 100644 index 00000000..7ad57e42 --- /dev/null +++ b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/Dockerfile @@ -0,0 +1,75 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +FROM ubuntu:18.04 + +RUN apt-get update +RUN apt-get -y install \ + build-essential \ + gcc-8 g++-8 \ + libomp-dev + +RUN rm -rf /usr/include/c++/7.5.0 +RUN rm -rf /usr/include/c++/7 +RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7.5.0 +RUN rm -rf /usr/include/x86_64-linux-gnu/c++/7 +RUN rm -rf /usr/lib/gcc/x86_64-linux-gnu/7 + +# Fix invalid links +WORKDIR /lib64 + +# Fix /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 +# cd lib64/ +# sudo ln -sfn ../lib/x86_64-linux-gnu/ld-2.27.so ./ld-linux-x86-64.so.2 +RUN ln -sfn ../lib/x86_64-linux-gnu/ld-2.27.so ./ld-linux-x86-64.so.2 + +WORKDIR /usr/lib/x86_64-linux-gnu + +# /usr/lib/x86_64-linux-gnu/libutil.so -> /lib/x86_64-linux-gnu/libutil.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libutil.so.1 ./libutil.so +# /usr/lib/x86_64-linux-gnu/libnsl.so -> /lib/x86_64-linux-gnu/libnsl.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnsl.so.1 ./libnsl.so +# /usr/lib/x86_64-linux-gnu/libcidn.so -> /lib/x86_64-linux-gnu/libcidn.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libcidn.so.1 ./libcidn.so +# /usr/lib/x86_64-linux-gnu/libnss_dns.so -> /lib/x86_64-linux-gnu/libnss_dns.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_dns.so.2 ./libnss_dns.so +# /usr/lib/x86_64-linux-gnu/libnss_hesiod.so -> /lib/x86_64-linux-gnu/libnss_hesiod.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_hesiod.so.2 ./libnss_hesiod.so +# /usr/lib/x86_64-linux-gnu/librt.so -> /lib/x86_64-linux-gnu/librt.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/librt.so.1 ./librt.so +# /usr/lib/x86_64-linux-gnu/libnss_nisplus.so -> /lib/x86_64-linux-gnu/libnss_nisplus.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_nisplus.so.2 ./libnss_nisplus.so +# /usr/lib/x86_64-linux-gnu/libcrypt.so -> /lib/x86_64-linux-gnu/libcrypt.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libcrypt.so.1 ./libcrypt.so +# /usr/lib/x86_64-linux-gnu/libnss_compat.so -> /lib/x86_64-linux-gnu/libnss_compat.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_compat.so.2 ./libnss_compat.so +# /usr/lib/x86_64-linux-gnu/libBrokenLocale.so -> /lib/x86_64-linux-gnu/libBrokenLocale.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libBrokenLocale.so.1 ./libBrokenLocale.so +# /usr/lib/x86_64-linux-gnu/libnss_files.so -> /lib/x86_64-linux-gnu/libnss_files.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_files.so.2 ./libnss_files.so +# /usr/lib/x86_64-linux-gnu/libresolv.so -> /lib/x86_64-linux-gnu/libresolv.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libresolv.so.2 ./libresolv.so +# /usr/lib/x86_64-linux-gnu/libnss_nis.so -> /lib/x86_64-linux-gnu/libnss_nis.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libnss_nis.so.2 ./libnss_nis.so +# /usr/lib/x86_64-linux-gnu/libthread_db.so -> /lib/x86_64-linux-gnu/libthread_db.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libthread_db.so.1 ./libthread_db.so +# /usr/lib/x86_64-linux-gnu/libanl.so -> /lib/x86_64-linux-gnu/libanl.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libanl.so.1 ./libanl.so +# /usr/lib/x86_64-linux-gnu/libdl.so -> /lib/x86_64-linux-gnu/libdl.so.2 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libdl.so.2 ./libdl.so +# /usr/lib/x86_64-linux-gnu/libmvec.so -> /lib/x86_64-linux-gnu/libmvec.so.1 +RUN ln -sfn ../../../lib/x86_64-linux-gnu/libmvec.so.1 ./libmvec.so + +WORKDIR /root diff --git a/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/create-sysroot.sh b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/create-sysroot.sh new file mode 100755 index 00000000..2de0dc17 --- /dev/null +++ b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/create-sysroot.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " +fi + +SYSROOT="$(basename "$(pwd)")" +CONTAINER=$(echo "$SYSROOT" | sed -E 's/.*ubuntu([0-9]+).*/u\1sysroot/') + +echo "Please enter sysroot version (default: 0.1.0):" +read VERSION +if [ -z "$VERSION" ]; then + VERSION="0.1.0" +fi + +ARCH_NAME=$SYSROOT-$VERSION + +# Remove old files and image +rm -rf /tmp/$ARCH_NAME +docker rm -f $CONTAINER +docker rmi -f $ARCH_NAME:latest + +# Create docker image from Dockerfile +echo -e "\nBuilding docker image $ARCH_NAME:latest" +docker build -t $ARCH_NAME:latest . + +# Run docker image +echo -e "\nRunning docker image $ARCH_NAME:latest, container name $CONTAINER" +docker run -d --name $CONTAINER $ARCH_NAME:latest bash -c "sleep 20" + +echo -e "\nCopying files from docker container..." +mkdir /tmp/$ARCH_NAME + +# Copy needed directories from Docker image +docker cp $CONTAINER:/lib /tmp/$ARCH_NAME/ +docker cp $CONTAINER:/lib64 /tmp/$ARCH_NAME/ +docker cp $CONTAINER:/usr /tmp/$ARCH_NAME/ +# Remove not used directories +rm -rf /tmp/$ARCH_NAME/lib/cpp +rm -rf /tmp/$ARCH_NAME/usr/bin +rm -rf /tmp/$ARCH_NAME/usr/games +rm -rf /tmp/$ARCH_NAME/usr/sbin +rm -rf /tmp/$ARCH_NAME/usr/share +rm -rf /tmp/$ARCH_NAME/usr/src + +echo -e "\nCreating /tmp/$ARCH_NAME.tar.xz archive..." +XZ_OPT="-T8" +tar -cJf /tmp/$ARCH_NAME.tar.xz -C /tmp/ $ARCH_NAME \ No newline at end of file diff --git a/cc/config/sysroot_ubuntu18_x86_64.BUILD b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/sysroot_x86_64_ubuntu18.BUILD similarity index 92% rename from cc/config/sysroot_ubuntu18_x86_64.BUILD rename to cc/config/sysroot_x86_64_ubuntu18_gcc8.4/sysroot_x86_64_ubuntu18.BUILD index a5cf62a4..b9050204 100644 --- a/cc/config/sysroot_ubuntu18_x86_64.BUILD +++ b/cc/config/sysroot_x86_64_ubuntu18_gcc8.4/sysroot_x86_64_ubuntu18.BUILD @@ -162,9 +162,9 @@ cc_toolchain_import( additional_libs = [ "lib/x86_64-linux-gnu/librt-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), "lib/x86_64-linux-gnu/librt.so.1", - "usr/lib/x86_64-linux-gnu/librt.so", - "usr/lib/x86_64-linux-gnu/librt.a", ], + shared_library = "usr/lib/x86_64-linux-gnu/librt.so", + static_library = "usr/lib/x86_64-linux-gnu/librt.a", visibility = ["//visibility:private"], ) @@ -187,13 +187,25 @@ cc_toolchain_import( ], ) -# This is a group of all the system libraries we need. The actual glibc library is split -# out to fix link ordering problems that cause false undefined symbol positives. +# Application Programming Interface (API) for shared-memory parallel programming. cc_toolchain_import( - name = "glibc", + name = "openmp", + additional_libs = glob([ + "usr/lib/x86_64-linux-gnu/libgomp*", + "usr/lib/x86_64-linux-gnu/libomp*", + ]), visibility = ["//visibility:public"], +) + +# This is a group of all the system libraries we need. The actual essential libraries is split +# out to fix link ordering problems that cause false undefined symbol positives. +cc_toolchain_import( + name = "libs", deps = [ ":dynamic_linker", ":libc", + ":openmp", + ":pthread", ], + visibility = ["//visibility:public"], ) diff --git a/cc/deps/cc_toolchain_deps.bzl b/cc/deps/cc_toolchain_deps.bzl index 9f76ad64..78b3f3de 100644 --- a/cc/deps/cc_toolchain_deps.bzl +++ b/cc/deps/cc_toolchain_deps.bzl @@ -59,13 +59,14 @@ def cc_toolchain_deps(): if "sysroot_linux_x86_64_glibc_2_27" not in native.existing_rules(): # C++17, manylinux_2_27, gcc-8 + # TODO: !!!!!!!!!!!!!!! Add C++ patch !!!!!!!!!!!!!!!! mirrored_http_archive( name = "sysroot_linux_x86_64_glibc_2_27", - sha256 = "7d9300ec03d008e96f0098dfcd4e9974dd64f2d5fccdd0f1a2b2d4af63301a04", - mirrored_tar_sha256 = "8680378000cf63647db5421377fbdb6a4fe98e0207b87f7cfec51883bde587aa", - urls = tf_mirror_urls("https://storage.googleapis.com/ml-sysroot-testing/ubuntu18_x86_64_sysroot_gcc8_patched-0.1.0.tar.xz"), - build_file = Label("//cc/config:sysroot_ubuntu18_x86_64.BUILD"), - strip_prefix = "ubuntu18_x86_64_sysroot_gcc8_patched-0.1.0", + sha256 = "33d65928d3c0a79702b10ceac2a172666aa8997822abc3d10f1ce0ba1fe7c1bf", + mirrored_tar_sha256 = "18496de0f6eb0dd4cfbab4b618c0a50e8082989779acd048b68e760bf4d5b7d5", + urls = tf_mirror_urls("https://storage.googleapis.com/ml-sysroot-testing/sysroot_x86_64_ubuntu18_gcc8.4-0.2.0.tar.xz"), + build_file = Label("//cc/config/sysroot_x86_64_ubuntu18_gcc8.4:sysroot_x86_64_ubuntu18.BUILD"), + strip_prefix = "sysroot_x86_64_ubuntu18_gcc8.4-0.2.0", ) if "sysroot_linux_x86_64_glibc_2_31" not in native.existing_rules(): @@ -106,11 +107,11 @@ def cc_toolchain_deps(): # C++17, manylinux_2_27, gcc-8 mirrored_http_archive( name = "sysroot_linux_aarch64_glibc_2_27", - sha256 = "31a285faccb6996c16acde8ef6841841d591f73196dc5b7bdd9cf55b7f0c35a1", - mirrored_tar_sha256 = "23989e1c4184b472ffcacf04cfeb7c9e108cb4126aeadb8a326597795b47f175", - urls = tf_mirror_urls("https://storage.googleapis.com/ml-sysroot-testing/sysroot_aarch64_ubuntu18_gcc8.4-0.1.0.tar.xz"), - build_file = Label("//cc/config:sysroot_ubuntu18_aarch64.BUILD"), - strip_prefix = "sysroot_aarch64_ubuntu18_gcc8.4-0.1.0", + sha256 = "6168a4d40caed088a59c7c9f3c99900e1795002e8aaca43522a6391c05988c2e", + mirrored_tar_sha256 = "854dce12fa5a92001ac728f6b7a2101b3cdb0356b83e987022aaa7b2a4b77202", + urls = tf_mirror_urls("https://storage.googleapis.com/ml-sysroot-testing/sysroot_aarch64_ubuntu18_gcc8.4-0.2.0.tar.xz"), + build_file = Label("//cc/config/sysroot_aarch64_ubuntu18_gcc8.4:sysroot_aarch64_ubuntu18.BUILD"), + strip_prefix = "sysroot_aarch64_ubuntu18_gcc8.4-0.2.0", ) if "sysroot_linux_aarch64_glibc_2_31" not in native.existing_rules(): diff --git a/cc/deps/sysroot_linux.BUILD.tpl b/cc/deps/sysroot_linux.BUILD.tpl index 81964bb2..6e99d237 100644 --- a/cc/deps/sysroot_linux.BUILD.tpl +++ b/cc/deps/sysroot_linux.BUILD.tpl @@ -44,13 +44,7 @@ alias( ) alias( - name = "glibc", - actual = "@@%{sysroot_repo_name}//:glibc", - visibility = ["//visibility:public"], -) - -alias( - name = "pthread", - actual = "@@%{sysroot_repo_name}//:pthread", + name = "libs", + actual = "@@%{sysroot_repo_name}//:libs", visibility = ["//visibility:public"], ) diff --git a/cc/impls/darwin_aarch64_darwin_aarch64/BUILD b/cc/impls/darwin_aarch64_darwin_aarch64/BUILD index 2f2fb10e..498235bc 100644 --- a/cc/impls/darwin_aarch64_darwin_aarch64/BUILD +++ b/cc/impls/darwin_aarch64_darwin_aarch64/BUILD @@ -43,8 +43,7 @@ cc_toolchain_import( "@sysroot_darwin_aarch64//:includes_c", "@llvm_darwin_aarch64//:includes", "@sysroot_darwin_aarch64//:includes_system", - "@sysroot_darwin_aarch64//:glibc", - "@sysroot_darwin_aarch64//:pthread", + "@sysroot_darwin_aarch64//:libs", ], visibility = ["//visibility:public"], ) diff --git a/cc/impls/linux_aarch64_linux_aarch64/BUILD b/cc/impls/linux_aarch64_linux_aarch64/BUILD index 63fe51a8..f88bfc38 100644 --- a/cc/impls/linux_aarch64_linux_aarch64/BUILD +++ b/cc/impls/linux_aarch64_linux_aarch64/BUILD @@ -54,8 +54,7 @@ cc_toolchain_import( "@sysroot_linux_aarch64//:includes_c", "@llvm_linux_aarch64//:includes", "@sysroot_linux_aarch64//:includes_system", - "@sysroot_linux_aarch64//:glibc", - "@sysroot_linux_aarch64//:pthread", + "@sysroot_linux_aarch64//:libs", ], visibility = ["//visibility:public"], ) diff --git a/cc/impls/linux_aarch64_linux_aarch64_cuda/BUILD b/cc/impls/linux_aarch64_linux_aarch64_cuda/BUILD index 1c70dfcd..20db98fc 100644 --- a/cc/impls/linux_aarch64_linux_aarch64_cuda/BUILD +++ b/cc/impls/linux_aarch64_linux_aarch64_cuda/BUILD @@ -96,8 +96,7 @@ cc_toolchain_import( "@sysroot_linux_aarch64//:includes_c", "@llvm_linux_aarch64//:includes", "@sysroot_linux_aarch64//:includes_system", - "@sysroot_linux_aarch64//:glibc", - "@sysroot_linux_aarch64//:pthread", + "@sysroot_linux_aarch64//:libs", "@llvm_linux_aarch64//:libclang_rt", ], visibility = ["//visibility:public"], diff --git a/cc/impls/linux_x86_64_darwin_aarch64/BUILD b/cc/impls/linux_x86_64_darwin_aarch64/BUILD index e9c41d49..53bc9172 100644 --- a/cc/impls/linux_x86_64_darwin_aarch64/BUILD +++ b/cc/impls/linux_x86_64_darwin_aarch64/BUILD @@ -43,8 +43,7 @@ cc_toolchain_import( "@sysroot_darwin_aarch64//:includes_c", "@llvm_linux_x86_64//:includes", "@sysroot_darwin_aarch64//:includes_system", - "@sysroot_darwin_aarch64//:glibc", - "@sysroot_darwin_aarch64//:pthread", + "@sysroot_darwin_aarch64//:libs", ], visibility = ["//visibility:public"], ) diff --git a/cc/impls/linux_x86_64_linux_aarch64/BUILD b/cc/impls/linux_x86_64_linux_aarch64/BUILD index c11a767f..2f77dcdf 100644 --- a/cc/impls/linux_x86_64_linux_aarch64/BUILD +++ b/cc/impls/linux_x86_64_linux_aarch64/BUILD @@ -54,8 +54,7 @@ cc_toolchain_import( "@sysroot_linux_aarch64//:includes_c", "@llvm_linux_x86_64//:includes", "@sysroot_linux_aarch64//:includes_system", - "@sysroot_linux_aarch64//:glibc", - "@sysroot_linux_aarch64//:pthread", + "@sysroot_linux_aarch64//:libs", ], visibility = ["//visibility:public"], ) diff --git a/cc/impls/linux_x86_64_linux_x86_64/BUILD b/cc/impls/linux_x86_64_linux_x86_64/BUILD index 26d0e24c..207e80c2 100644 --- a/cc/impls/linux_x86_64_linux_x86_64/BUILD +++ b/cc/impls/linux_x86_64_linux_x86_64/BUILD @@ -48,8 +48,7 @@ cc_toolchain_import( "@sysroot_linux_x86_64//:includes_c", "@llvm_linux_x86_64//:includes", "@sysroot_linux_x86_64//:includes_system", - "@sysroot_linux_x86_64//:glibc", - "@sysroot_linux_x86_64//:pthread", + "@sysroot_linux_x86_64//:libs", "@llvm_linux_x86_64//:libclang_rt", ], visibility = ["//visibility:public"], diff --git a/cc/impls/linux_x86_64_linux_x86_64_cuda/BUILD b/cc/impls/linux_x86_64_linux_x86_64_cuda/BUILD index dbe4766b..4cfde5d1 100644 --- a/cc/impls/linux_x86_64_linux_x86_64_cuda/BUILD +++ b/cc/impls/linux_x86_64_linux_x86_64_cuda/BUILD @@ -98,8 +98,7 @@ cc_toolchain_import( "@sysroot_linux_x86_64//:includes_c", "@llvm_linux_x86_64//:includes", "@sysroot_linux_x86_64//:includes_system", - "@sysroot_linux_x86_64//:glibc", - "@sysroot_linux_x86_64//:pthread", + "@sysroot_linux_x86_64//:libs", "@llvm_linux_x86_64//:libclang_rt", ], visibility = ["//visibility:public"], diff --git a/cc/impls/linux_x86_64_linux_x86_64_sycl/BUILD b/cc/impls/linux_x86_64_linux_x86_64_sycl/BUILD index 5342ac34..5660d782 100644 --- a/cc/impls/linux_x86_64_linux_x86_64_sycl/BUILD +++ b/cc/impls/linux_x86_64_linux_x86_64_sycl/BUILD @@ -77,8 +77,7 @@ cc_toolchain_import( "@sysroot_linux_x86_64//:includes_c", "@oneapi//:includes", "@sysroot_linux_x86_64//:includes_system", - "@sysroot_linux_x86_64//:glibc", - "@sysroot_linux_x86_64//:pthread", + "@sysroot_linux_x86_64//:libs", "@oneapi//:core", "@oneapi//:mkl", "@oneapi//:libclang_rt", diff --git a/cc/tests/cpu/BUILD b/cc/tests/cpu/BUILD index c0d85915..d1846b21 100644 --- a/cc/tests/cpu/BUILD +++ b/cc/tests/cpu/BUILD @@ -14,8 +14,9 @@ # ============================================================================== load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test") -load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") ############################################# # C @@ -106,6 +107,10 @@ cc_binary( name = "protobuf", srcs = ["protobuf.cc"], deps = [":protobuf_hello_lib"], + linkopts = [ + "-fopenmp", + "-lomp", + ], ) cc_test(