Skip to content

@weak attribute does not appear to work for --target windows-x64 #2396

@NotsoanoNimus

Description

@NotsoanoNimus

Repro:

module component::weak_module;
import std::io;
fn void do_thing() @weak @extern("do_thing") @nostrip => io::printn("weak");

module component::strong_module;
import std::io;
fn void do_thing() @export("do_thing") @nostrip => io::printn("strong");

module main;
extern fn void do_thing();
fn void main() => do_thing();

Build command:
c3c compile-only main4.c3 --obj --link-libc=no --no-entry --target windows-x64

Inspecting the resulting COFF object file does not show a weak symbol as it should. And attempting to link creates a duplicate symbol error.

~$ nm ./obj/windows-x64/component.weak_module.obj | grep do_thing
0000000000000000 T do_thing
~$
~$  # now try linking it
~$ c3c compile-run main4.c3 --link-libc=no --target windows-x64
lld-link: error: duplicate symbol: do_thing
>>> defined at /path/main4.c3:7
>>>            /tmp/c3cXIZoBZU/obj/windows-x64/component.strong_module.obj
>>> defined at /tmp/c3cXIZoBZU/obj/windows-x64/component.weak_module.obj
Failed to create an executable: (null)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingDiscussion neededThis feature needs discussion to iron out details

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions