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

cross module inlining fails when code contains switch with string argument and at least 7 cases #4808

Open
KytoDragon opened this issue Dec 31, 2024 · 1 comment

Comments

@KytoDragon
Copy link
Contributor

The following code

int main(string[] a) {
    switch (a[0]) {
        case "one":
            return 1;
        case "two":
            return 2;
        case "three":
            return 3;
        case "four":
            return 4;
        case "five":
            return 5;
        case "six":
            return 6;
        case "seven":
            return 7;
        default:
            return 0;
    }
}

when compiled with these options:

ldc2 -enable-inlining --enable-cross-module-inlining=true -Isource source\main.d -ofd-test.exe -link-internally

results in the following error:

lld-link: error: undefined symbol: _D4core8internal7switch___T8__switchTyaVxAyaa3_6f6e65VxQoa3_736978VxQBba3_74776fVxQBpa4_66697665VxQCfa4_666f7572VxQCva5_736576656eVxQDna5_7468726565ZQEsFNaNbNiNfMxQEsZ5casesyG7Aa
>>> referenced by d-test.obj:(_D4core8internal7switch___T8__switchTyaVxAyaa3_6f6e65VxQoa3_736978VxQBba3_74776fVxQBpa4_66697665VxQCfa4_666f7572VxQCva5_736576656eVxQDna5_7468726565ZQEsFNaNbNiNfMxQEsZi)
Error: linking with LLD failed

The identifier in question is defined in druntime here.
Tested on Windows 10 with LDC 1.40.0.

@JohanEngelen
Copy link
Member

Can you help out and test with a small testcase whether cross-module inlining works for static variables inside the inlined function? Thanks

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

2 participants