Skip to content

Mold doesn't detect undefined symbols used in shared libraries #659

@Ulmo-F

Description

@Ulmo-F

First create a library with some missing implementation:

// Library.h
#pragma once
void f();
void g();
// Library.cpp
#include "library.h"

void f() {
    g();
}

// void g() { }

Then use it in separate executable :

// main.cpp
#include "library.h"

int main() {
    f();
    return 0;
}
# CMakeLists.txt
project(test)
add_library(library SHARED library.cpp)
add_executable(main main.cpp)
target_link_libraries(main PUBLIC library)

Mold generates an unusable executable ./main: symbol lookup error: libLibrary.so: undefined symbol: _Z1gv.
I didn't find an option which could enable detection, but if there is one I tend to think it should be activated by default.

(On its side, GCC's linker does report libLibrary.so: undefined reference to g()'`)

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