This is a copy of the repository from semarie (with very few differences): https://github.com/semarie/openbsd-ziglibc
 
 
 
 
Go to file
Philippe Pittoli d278fb64bf Change default OpenBSD version. 2024-03-23 01:39:57 +01:00
tests initial import 2021-11-08 18:54:45 +00:00
LICENSE.txt add ISC license file 2021-11-08 19:00:39 +00:00
README.md update README.md for tests/ directory 2021-11-08 19:04:58 +00:00
build-ziglibc.sh initial import 2021-11-08 18:54:45 +00:00
makefile Change default OpenBSD version. 2024-03-23 01:39:57 +01:00

README.md

OpenBSD ZIG_LIBC support

Simple shell script to build a ZIG_LIBC environment for Zig targeting OpenBSD.

Usage

$ ./build-ziglibc.sh
usage: ./build-ziglibc.sh url output-dir
  • url : URL pointing to OpenBSD sets.

    Typical url to use: https://cdn.openbsd.org/pub/OpenBSD/version/platform/

    Please note that OpenBSD officially support only the two last released versions. Snapshots url is also valid for targeting -current, but be aware that it is a moving target.

    Refer to supported platforms list from OpenBSD site web for the name used.

  • output-dir : where to put the environment.

    Prefer absolute path: it will be used in generated libc.conf file.

    The directory will be created.

Examples of url

Use the environment

$ ZIG_LIBC=path/to/amd64/libc.conf zig build-exe -target x86_64-openbsd -o tests/helloz tests/hello.zig
$ ZIG_LIBC=path/to/amd64/libc.conf zig cc -target x86_64-openbsd -o tests/helloc tests/hello.c

Make shell wrapper

For easy use of crosscompilation, you could create a shell wrapper named x86_64-openbsd-cc:

#!/bin/sh
exec env ZIG_LIBC=path/to/amd64/libc.conf zig cc -target x86_64-openbsd "$@"

And do the same for x86_64-openbsd-c++, x86_64-openbsd-ar, …