Skip to content
Merged
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
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=6.2.0
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build:aarch64_sysroot --incompatible_enable_cc_toolchain_resolution
build:aarch64_sysroot --platforms=@rules_swiftnav//platforms:aarch64_bullseye_graviton2

build:x86_64_sysroot --incompatible_enable_cc_toolchain_resolution
build:x86_64_sysroot --@rules_swiftnav//cc:enable_sysroot=true

try-import %workspace%/.bazelrc.user
22 changes: 21 additions & 1 deletion .github/workflows/bullseye-aarch64-sysroot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- .github/workflows/bullseye-aarch64-sysroot.yaml
push:
tags:
- "bullseye-aarch64-sysroot-*"
- "bullseye-sysroot-*"

jobs:
toolchains:
Expand All @@ -21,6 +21,26 @@ jobs:
run: ./sysroot/sysroot-creator.sh build arm64

- name: Upload sysroot
uses: actions/upload-artifact@v3
with:
name: debian_bullseye_aarch64_sysroot.tar.xz
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel cache
uses: actions/cache@v1
with:
path: "~/.cache/bazel"
key: bazel

- name: Copy sysroot
run: cp sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz debian_bullseye_aarch64_sysroot.tar.xz

- name: Test sysroot
run: bazel build --config=aarch64_sysroot //sysroot/...

- name: Release sysroot
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v1-release
with:
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/bullseye-x86_64-sysroot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- .github/workflows/bullseye-x86_64-sysroot.yaml
push:
tags:
- "bullseye-x86_64-sysroot-*"
- "bullseye-sysroot-*"

jobs:
toolchains:
Expand All @@ -21,6 +21,26 @@ jobs:
run: ./sysroot/sysroot-creator.sh build amd64

- name: Upload sysroot
uses: actions/upload-artifact@v3
with:
name: debian_bullseye_x86_64_sysroot.tar.xz
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel cache
uses: actions/cache@v1
with:
path: "~/.cache/bazel"
key: bazel

- name: Copy sysroot
run: cp sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz debian_bullseye_x86_64_sysroot.tar.xz

- name: Test sysroot
run: bazel build --config=x86_64_sysroot //sysroot/...

- name: Release sysroot
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v1-release
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build-x86/
output/
llvm-obfuscator-*.txz
sysroot/out
/bazel-*
.bazelrc.user
Empty file added BUILD.bazel
Empty file.
55 changes: 55 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
workspace(name = "swift-toolchains")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

http_archive(
name = "rules_swiftnav",
sha256 = "91a230cf400921189f1654ebe7ca10305e89f3d8cccc0c7486e6fc8886ac0d1b",
strip_prefix = "rules_swiftnav-3262a9ccd01951aa45576be3db102f03b84047eb",
url = "https://github.com/swift-nav/rules_swiftnav/archive/3262a9ccd01951aa45576be3db102f03b84047eb.tar.gz",
)

load("@rules_swiftnav//cc:repositories.bzl", "register_swift_cc_toolchains", "swift_cc_toolchain")

swift_cc_toolchain()

register_swift_cc_toolchains()

load("@rules_swiftnav//tools:local_archive.bzl", "local_archive")

local_archive(
name = "aarch64-sysroot",
build_file_content = """
filegroup(
name = "aarch64-sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
""",
src = "//:debian_bullseye_aarch64_sysroot.tar.xz",
)

local_archive(
name = "x86_64-sysroot",
build_file_content = """
filegroup(
name = "x86_64-sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
""",
src = "//:debian_bullseye_x86_64_sysroot.tar.xz",
)
22 changes: 22 additions & 0 deletions sysroot/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cc_binary(
name = "uuid",
srcs = ["test/uuid.cc"],
linkopts = [
"-luuid",
],
)

cc_binary(
name = "foo",
srcs = ["test/lapack.cc"],
linkopts = [
"-Lexternal/aarch64-sysroot/usr/lib/aarch64-linux-gnu/blas",
"-Lexternal/aarch64-sysroot/usr/lib/aarch64-linux-gnu/lapack",
"-Lexternal/x86_64-sysroot/usr/lib/x86_64-linux-gnu/blas",
"-Lexternal/x86_64-sysroot/usr/lib/x86_64-linux-gnu/lapack",
"-lm",
"-lpthread",
"-lblas",
"-llapack",
],
)
4 changes: 4 additions & 0 deletions sysroot/generated_package_lists/bullseye.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_amd64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_amd64.deb
4 changes: 4 additions & 0 deletions sysroot/generated_package_lists/bullseye.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_arm64.deb
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_arm64.deb
4 changes: 4 additions & 0 deletions sysroot/sysroot-creator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ DEBIAN_PACKAGES="\
uuid-dev
libgcc-10-dev
libgcc-s1
libblas-dev
libblas3
liblapack-dev
liblapack3
"

DEBIAN_PACKAGES_AMD64="
Expand Down
42 changes: 42 additions & 0 deletions sysroot/test/lapack.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// LAPACK test code
//compile with: g++ main.cpp -llapack -lblas -o testprog

#include <iostream>
#include <vector>

using namespace std;

extern "C" void dgetrf_(int* dim1, int* dim2, double* a, int* lda, int* ipiv, int* info);
extern "C" void dgetrs_(char *TRANS, int *N, int *NRHS, double *A, int *LDA, int *IPIV, double *B, int *LDB, int *INFO );

int main()
{
char trans = 'N';
int dim = 2;
int nrhs = 1;
int LDA = dim;
int LDB = dim;
int info;

vector<double> a, b;

a.push_back(1);
a.push_back(1);
a.push_back(1);
a.push_back(-1);

b.push_back(2);
b.push_back(0);

int ipiv[3];

dgetrf_(&dim, &dim, &*a.begin(), &LDA, ipiv, &info);
dgetrs_(&trans, &dim, &nrhs, & *a.begin(), &LDA, ipiv, & *b.begin(), &LDB, &info);


std::cout << "solution is:";
std::cout << "[" << b[0] << ", " << b[1] << ", " << "]" << std::endl;
std::cout << "Info = " << info << std::endl;

return(0);
}
8 changes: 8 additions & 0 deletions sysroot/test/uuid.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <uuid/uuid.h>
#include <iostream>

int main() {
uuid_t uuid{};
uuid_generate_random(uuid);
std::cout << "uuid: " << uuid << std::endl;
}