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

LLVM ERROR: Associative COMDAT symbol 'std.time.Duration.to_nano' is not a key for its COMDAT. #1704

Open
lerno opened this issue Dec 21, 2024 Discussed in #1702 · 3 comments
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works

Comments

@lerno
Copy link
Collaborator

lerno commented Dec 21, 2024

Discussed in #1702

Originally posted by LukyGuyLucky December 21, 2024
Below execise is modified from https://github.com/c3lang/c3c/blob/master/test/unit/stdlib/threads/mutex.c3,it compiles and runs fine when using below commandline:
c3c compile-run mutex01.c3

but when I tried it with
c3c compile -Oz mutex01.c3
the compiler says:

LLVM ERROR: Associative COMDAT symbol 'std.time.Duration.to_nano' is not a key for its COMDAT.

So was I missing something?

module mutex01;

import std::thread;
import std::os;
import std::io;
const TEST_MAGNITUDE = 10;

int counter;
fn void! own_mutex(Mutex* m)
{
    m.lock()!!;
    for(int i=0;i<5;i++)
    {
        counter++;
        io::print(counter);
        thread::sleep_ms(100);
        counter++;
        io::print(counter);
        thread::sleep_ms(50);
    }
    m.unlock()!!;
}

fn void! ensure_owner_checks() 
{
    Mutex m;
    m.init()!;
	
    Thread[3 * TEST_MAGNITUDE] threads;
    
    foreach(&t : threads)
    {
        t.create((ThreadFn)&own_mutex, &m)!;
    }

    foreach(&t : threads)
    {
        t.join()!;
    }

    own_mutex(&m)!;
    
}
fn void main()
{
   
    ensure_owner_checks()!!;
    io::printn("Done.");
}

```</div>
@lerno lerno added the Bug Something isn't working label Dec 21, 2024
@lerno
Copy link
Collaborator Author

lerno commented Dec 21, 2024

This only happens for single module compilation.

@lerno lerno added the In Progress This task is currently being worked on label Dec 21, 2024
@lerno
Copy link
Collaborator Author

lerno commented Dec 26, 2024

There seems to be an optimization done by LLVM that doesn't work correctly on windows.

lerno added a commit that referenced this issue Dec 26, 2024
lerno added a commit that referenced this issue Dec 26, 2024
lerno added a commit that referenced this issue Dec 26, 2024
lerno added a commit that referenced this issue Dec 26, 2024
@lerno lerno added Fixed Needs Verification Fixed, but needs verification that it works and removed In Progress This task is currently being worked on labels Dec 26, 2024
@lerno
Copy link
Collaborator Author

lerno commented Dec 26, 2024

Using weak_odr inhibits the optimization that make this happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works
Projects
None yet
Development

No branches or pull requests

1 participant