Skip to content
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

Bad interaction of -fuse-ld=lld and statically linked libc++ #388

Open
rao94583 opened this issue Sep 12, 2024 · 0 comments
Open

Bad interaction of -fuse-ld=lld and statically linked libc++ #388

rao94583 opened this issue Sep 12, 2024 · 0 comments

Comments

@rao94583
Copy link

rao94583 commented Sep 12, 2024

Our platform is Ubuntu 22.04. We import the OpenUSD package as a prebuilt tarball (built with clang) into bazel targets for use within our code-base. A small test program that exercises some basic functionality in OpenUSD crashes during static initialization with an error like this:

a_rao@a-rao-ubuntu:$ bazel test //examples/hello_world:test_usd 
test_usd: mbrtowc.c:104: __mbrtowc: Assertion `__mbsinit (data.__statep)' failed.
Aborted (core dumped)

After much debugging, the culprit appears to be -fuse-ld=lld, which also apparently causes libc++.a, libc++abi.a and libunwind.a to be statically linked. Either of these by themselves is fine, but together, they cause the crash.

Also: using clang++ instead of clang also fixes the problem (without changing anything else).

The workaround is to add linkopts to the build rule for the test program:

cc.test(
    name = "test_usd",
    srcs = ["test_usd.cpp"],
    args = ["/tmp/hello_world.usda"],
    copts = [
        "-Wno-#pragma-messages",
        "-Wno-deprecated-volatile",
    ],
    linkopts = [
        "-fuse-ld=ld",
        "-lc++",
        "-lc++abi",
        "-lunwind",
    ],
    deps = [
        "//external/OpenUSD:usd_tf",
        "//external/OpenUSD:usd_usd",
        "//external/OpenUSD:usd_usdGeom",
    ],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant