Skip to content

lld: link errors still allow zig test to succeed #13235

Closed

Description

@jacobly0

Zig Version

0.10.0-dev.4472+a4eb221b9

Steps to Reproduce

echo > repro.zig
zig test repro.zig
echo $?
echo 'extern fn this_function_does_not_exist() void; test { this_function_does_not_exist(); }' > repro.zig
zig test repro.zig
echo $?

Expected Behavior

$ echo > repro.zig
$ zig test repro.zig
All 0 tests passed.
$ echo $?
0
$ echo 'extern fn this_function_does_not_exist() void; test { this_function_does_not_exist(); }' > repro.zig
$ zig test repro.zig
LLD Link... ld.lld: error: undefined symbol: this_function_does_not_exist
>>> referenced by repro.zig:1 (./repro.zig:1)
>>>               /home/jacob/Source/zig/zig-cache/o/836f76c54df629e0f8e38b174388b09f/test.o:(repro.test_0)
$ echo $?
1

Actual Behavior

$ echo > repro.zig
$ zig test repro.zig
All 0 tests passed.
$ echo $?
0
$ echo 'extern fn this_function_does_not_exist() void; test { this_function_does_not_exist(); }' > repro.zig
$ zig test repro.zig
LLD Link... ld.lld: error: undefined symbol: this_function_does_not_exist
>>> referenced by repro.zig:1 (./repro.zig:1)
>>>               /home/jacob/Source/zig/zig-cache/o/836f76c54df629e0f8e38b174388b09f/test.o:(repro.test_0)
All 0 tests passed.
$ echo $?
0

Code path of note:

error.LLDReportedFailure => {}, // error reported through log.err

Workaround

Add std.process.exit(1) to the above case.

Activity

  1. added
    bug
    on Oct 20, 2022
  2. changed the title [-]lld: link errors silently allow tests to succeed[/-] [+]lld: link errors still allow `zig test` to succeed[/+] on Oct 20, 2022
  3. added
    frontend
    on Oct 20, 2022
  4. added this to the 0.10.1 milestone on Oct 20, 2022
  5. jacobly0 commented on Dec 2, 2022

    @jacobly0
    MemberAuthor

    Fixed by #13562.

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

    bugfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions