Skip to content

[C++20] [Modules] ld.lld: error: undefined symbol: initializer for module #421

@huangqinjin

Description

@huangqinjin

Steps to Reproduce

hello.cppm

module;

#if X == 1
#define EXPORT __declspec(dllexport)
#elif X == 2
#define EXPORT __attribute__((visibility("default")))
#elif X == 3
#define EXPORT
#endif

export module hello;

export EXPORT void f() {}

main.cpp

import hello;

int main()
{
    f();
}

commands

clang++ -std=c++20 -fmodule-output -shared hello.cppm -o hello.dll -DX=1
clang++ -std=c++20 -fprebuilt-module-path=. main.cpp -L. -lhello

-DX=1 results in ld.lld error, -DX=2 and -DX=3 have no error.
-DX=1 with windows version of Clang also has no error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions