downgrade glibc to 2.19 and update README
This commit is contained in:
55
README.md
55
README.md
@@ -1,39 +1,32 @@
|
||||
To run the example locally, first make sure `bazelisk` is on your PATH. Then
|
||||
# Bazel zig cc toolchain for Go
|
||||
|
||||
Test that things work at all:
|
||||
This is a prototype zig-cc toolchain for cgo programs with:
|
||||
|
||||
- glibc 2.19
|
||||
- musl.
|
||||
|
||||
# Testing
|
||||
|
||||
Building a cgo binary with glibc:
|
||||
|
||||
```
|
||||
$ bazelisk run //test:hello
|
||||
$ bazel build //test:gognu
|
||||
...
|
||||
Hello World!
|
||||
$ ../bazel-bin/test/gognu_/gognu
|
||||
hello, world
|
||||
$ file ../bazel-bin/test/gognu_/gognu
|
||||
../bazel-bin/test/gognu_/gognu: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, Go BuildID=redacted, with debug_info, not stripped
|
||||
```
|
||||
|
||||
Then test that you can run docker images:
|
||||
Build a cgo binary with musl:
|
||||
|
||||
```
|
||||
$ bazelisk run //test:hello_image
|
||||
$ bazel build --platforms @com_github_ziglang_zig//:platform_linux-x86_64-musl :gomusl
|
||||
...
|
||||
Hello World!
|
||||
```
|
||||
|
||||
Now we can check if C++ exceptions work locally:
|
||||
```
|
||||
$ bazelisk run //test:exception
|
||||
...
|
||||
will throw and expect to catch an error...
|
||||
caught: error
|
||||
done
|
||||
```
|
||||
|
||||
And whether or not they work in a docker container:
|
||||
```
|
||||
$ bazelisk run //test:exception_image
|
||||
```
|
||||
|
||||
If they *work*, then you'll see the same output as above. If not, you'll see:
|
||||
|
||||
```
|
||||
will throw and expect to catch an error...
|
||||
libc++abi: terminating with uncaught exception of type char const*
|
||||
$ file ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl
|
||||
../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, with debug_info, not stripped
|
||||
$ ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl
|
||||
hello, world
|
||||
```
|
||||
|
||||
If you want to try the above in a transient docker environment, you can do:
|
||||
@@ -43,6 +36,6 @@ $ docker run --rm -it -v $(pwd):/workspace debian:buster-slim
|
||||
# apt update && apt install curl ca-certificates --no-install-recommends -y && curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.7.5/bazelisk-linux-amd64 > /usr/bin/bazel && chmod +x /usr/bin/bazel
|
||||
# cd /workspace
|
||||
# export CC=/usr/bin/false
|
||||
# bazel run --platforms=@com_github_ziglang_zig//:x86_64-linux-gnu.2.28 //test:hello
|
||||
# bazel run --platforms=@com_github_ziglang_zig//:x86_64-linux-gnu.2.28 //test:exception
|
||||
```
|
||||
# bazel run --platforms @com_github_ziglang_zig//:platform_linux-x86_64-musl :gomusl
|
||||
# bazel run --platforms @com_github_ziglang_zig//:platform_linux-x86_64-glibc :gomusl
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user