-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig Version
0.10.0-dev.3028+337147068
Steps to Reproduce
Hit this one on #11168 and realized it's a more general problem for libraries compiled with Zig.
// foo.cpp
#include <system_error>
std::error_condition foo() {
return std::generic_category().default_error_condition(ENOENT);
}// main.cpp
#include <system_error>
std::error_condition foo();
int main() {
if (foo() != std::generic_category().default_error_condition(ENOENT)) {
fprintf(stderr, "error: errors compare unequal.\n");
}
}With clang:
$ clang++ foo.cpp -o libfoo.so -shared
$ clang++ main.cpp -lfoo -L. -lstdc++ -rpath . -o main
$ ./main
With zig c++:
$ zig c++ foo.cpp -o libfoo.so -shared
$ zig c++ main.cpp -lfoo -L. -lstdc++ -rpath . -o main
./build/zig c++ main.cpp -lfoo -L. -lstdc++ -rpath . -o main
zig: warning: -rpath .: 'linker' input unused [-Wunused-command-line-argument]
$ ./main
error: errors compare unequal.
Expected Behavior
Library should behave the same when compiled with Zig and with Clang.
Actual Behavior
Behavior diverges because Zig links libstdc++ statically by default
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.