-
Notifications
You must be signed in to change notification settings - Fork 19
Add steps to build with custom toolchains #217
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
3648f60
Add steps to build with custom toolchains
NoureldinYosri 68062cd
split
NoureldinYosri 7f5c18c
nit
NoureldinYosri 48725c6
nit
NoureldinYosri 436fd93
nit
NoureldinYosri 5dd9db9
fix
NoureldinYosri ca33c1b
nit
NoureldinYosri df39d88
nit
NoureldinYosri b79456a
revert pybind11 version
NoureldinYosri 79859dc
nit
NoureldinYosri b46c8d7
fix version
NoureldinYosri 3b42554
nit
NoureldinYosri 8b4ac3d
test
NoureldinYosri ded40c2
nit
NoureldinYosri 25ab5fb
nit
NoureldinYosri 5730e74
fix name
NoureldinYosri c9f0614
nit
NoureldinYosri a13e464
make ready
NoureldinYosri c64f53d
nit
NoureldinYosri fe8b976
change debian version
NoureldinYosri 4bd541b
change docker
NoureldinYosri 325c6a9
change docker
NoureldinYosri 6bb11f0
change docker image
NoureldinYosri 8af11e2
change docker image
NoureldinYosri fd4e434
fix command
NoureldinYosri c4781cf
update debian
NoureldinYosri 70d8cc5
update debian
NoureldinYosri bcabbcd
update debian
NoureldinYosri 49ae144
change source
NoureldinYosri 2b54b2b
nit
NoureldinYosri 4509096
change debian file
NoureldinYosri 7aad468
add -y
NoureldinYosri d37a102
add ls
NoureldinYosri 7165e9a
fix version
NoureldinYosri d22ef9a
final check
NoureldinYosri d58e930
final check
NoureldinYosri 963da80
ready
NoureldinYosri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # 1. Start a temporary background container named 'sysroot-builder' | ||
| docker run -d --name sysroot-builder debian:10 sleep 3600 | ||
|
|
||
| # 2. Run the installation and packaging process inside the container | ||
| docker exec sysroot-builder bash -c " | ||
| sed 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list -i | ||
|
|
||
| apt-get update && apt-get upgrade -y && apt-get install -y build-essential libc6-dev symlinks apt-utils | ||
|
|
||
| # Convert absolute symlinks to relative (CRITICAL so Clang doesn't read your host OS files) | ||
| symlinks -rc /lib /usr/lib /usr/include | ||
|
|
||
| # Create the staging directory | ||
| mkdir -p /sysroot/usr/lib /sysroot/usr/include /sysroot/lib /sysroot/lib64 | ||
|
|
||
| ldd --version | ||
|
|
||
| # Copy files while preserving symlinks (-a) | ||
| cp -a /usr/include/* /sysroot/usr/include/ | ||
| cp -a /usr/lib/* /sysroot/usr/lib/ | ||
| cp -a /lib/* /sysroot/lib/ 2>/dev/null || true | ||
| cp -a /lib64/* /sysroot/lib64/ 2>/dev/null || true | ||
|
|
||
| # Create a tarball inside the container | ||
| cd /sysroot && tar -czf /sysroot.tar.gz . | ||
| " | ||
|
|
||
| # 3. Copy the tarball from the container directly to your host machine | ||
| docker cp sysroot-builder:/sysroot.tar.gz ./sysroot.tar.gz | ||
|
|
||
| # 4. Extract the contents into your project and clean up | ||
| mkdir -p custom_sysroot | ||
| tar -xzf sysroot.tar.gz -C custom_sysroot | ||
| rm sysroot.tar.gz | ||
| docker rm -f sysroot-builder | ||
| ls -l -R custom_sysroot | ||
|
|
||
| # create custom_sysroot/BUILD | ||
| echo """filegroup( | ||
| name = \"sysroot\", | ||
| srcs = glob([\"**/*\"]), | ||
| visibility = [\"//visibility:public\"], | ||
| )""" > custom_sysroot/BUILD | ||
|
|
||
| # update MODULE.bazel to use the custom toolchain | ||
| echo """bazel_dep(name = \"toolchains_llvm\", version = \"1.6.0\") | ||
|
|
||
| llvm = use_extension(\"@toolchains_llvm//toolchain/extensions:llvm.bzl\", \"llvm\") | ||
| llvm.toolchain( | ||
| name = \"llvm_toolchain\", | ||
| llvm_version = \"17.0.6\", | ||
| ) | ||
|
|
||
| llvm.sysroot( | ||
| name = \"llvm_toolchain\", | ||
| label = \"//custom_sysroot:sysroot\", | ||
| targets = [\"linux-x86_64\"], | ||
| ) | ||
| use_repo(llvm, \"llvm_toolchain\") | ||
|
|
||
| register_toolchains(\"@llvm_toolchain//:all\") | ||
| """ >> MODULE.bazel | ||
|
|
||
|
|
||
| sudo apt-get update | ||
| sudo apt-get install -y libxml2 | ||
|
|
||
| cd custom_sysroot/lib64/ | ||
| rm -f ld-linux-x86-64.so.2 | ||
| ln -s ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2 | ||
| cd ../.. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.