Skip to content

add build.zig API for linking against libstdc++ #3936

Description

@dcao

I'm attempting to build a project which links in the hyperscan regex library. The build.zig script links to the hyperscan library and I have a zig source file which includes the hyperscan header file in a @cImport block. However, when I attempt to build the project with zig build, I get this error message:

lld: error: undefined symbol: __gxx_personality_v0
>>> referenced by libunwind.cpp
>>>               /home/david/.local/share/zig/stage1/o/O52Tz8yjwKTfxA_7ZFqf7o46uv59sKmBhDgOE31UEeWVeMBV0cLPD4GnzhB-Hkqz/libunwind.o:(DW.ref.__gxx_personality_v0) in archive /home/david/.local/share/zig/stage1/o/5ImJwmxLqixH7RSFicg8PiRam4oQs9H1Xb3dmdM5J2Rni9aDl1cboZirbXRsFt5r/libunwind.a

The following command exited with error code 1:
/nix/store/v7gp1yjd5dz0gzadxckz18c9k0ygy9xc-zig-0.5.0/bin/zig build-exe /home/david/dev/wordsmith/src/main.zig --library c --library hs --cache-dir /home/david/dev/wordsmith/zig-cache --name ws -isystem /nix/store/66jnj8nqsk9ir44y4fi2kpxb7r3crmqn-hyperscan-5.2.1-dev/include/hs -L /nix/store/islpcsy87hf3jspb7mwlgzgwsfkkinpy-hyperscan-5.2.1/lib -isystem /nix/store/66jnj8nqsk9ir44y4fi2kpxb7r3crmqn-hyperscan-5.2.1-dev/include -isystem /nix/store/p52h688mi6yb62wfsw2ibj3xm6vqq98v-gdb-8.3.1/include -isystem /nix/store/i5wf0wfyd4n4lnvksbbgbwllpq1mq743-valgrind-3.15.0-dev/include -isystem /nix/store/95gcjjxrafz14lcm1qlr0c22cllq0z0g-compiler-rt-7.1.0-dev/include -isystem /nix/store/66jnj8nqsk9ir44y4fi2kpxb7r3crmqn-hyperscan-5.2.1-dev/include -isystem /nix/store/p52h688mi6yb62wfsw2ibj3xm6vqq98v-gdb-8.3.1/include -isystem /nix/store/i5wf0wfyd4n4lnvksbbgbwllpq1mq743-valgrind-3.15.0-dev/include -isystem /nix/store/95gcjjxrafz14lcm1qlr0c22cllq0z0g-compiler-rt-7.1.0-dev/include -rpath /nix/store/8yflb7qdsj3qb791jsiwg67zhcvbxirc-lorri-keep-env-hack-wordsmith/lib64 -rpath /nix/store/8yflb7qdsj3qb791jsiwg67zhcvbxirc-lorri-keep-env-hack-wordsmith/lib --library-path /nix/store/islpcsy87hf3jspb7mwlgzgwsfkkinpy-hyperscan-5.2.1/lib --library-path /nix/store/p52h688mi6yb62wfsw2ibj3xm6vqq98v-gdb-8.3.1/lib --library-path /nix/store/islpcsy87hf3jspb7mwlgzgwsfkkinpy-hyperscan-5.2.1/lib --library-path /nix/store/p52h688mi6yb62wfsw2ibj3xm6vqq98v-gdb-8.3.1/lib --cache on

Build failed. The following command failed:
/home/david/dev/wordsmith/zig-cache/o/z56kk2rvgVc7NHq34aIRdQ-vtWKZuuPxTQrscrdjfBnSZIyXKXsJ0VTog_KCdiXB/build /nix/store/v7gp1yjd5dz0gzadxckz18c9k0ygy9xc-zig-0.5.0/bin/zig /home/david/dev/wordsmith /home/david/dev/wordsmith/zig-cache

My hunch is that the remedy would involve using libstdc++ by passing in --stdlib=libc++ or something similar to clang; however, I'm not sure if this is correct, and even if it was, there's no way to pass arbitrary flags to clang via the zig cli or a build.zig file, as far as I can tell.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    standard libraryThis issue involves writing Zig code for the standard library.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions