Skip to content

[LLD] unable to link a uncalled constructor function in static lib #144669

Open
@Eternalni

Description

@Eternalni

#include

extern "C" {

attribute((constructor(101), used, retain, section(".llvm.keep,.init.250"), noinline, visibility("hidden"))) static void
_init_cpu_features() {
__builtin_cpu_init();
std::cout << "?" << std::endl;
};
}

build this function to a static lib _initd.lib, link it by cmake: "set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_CURRENT_LIST_DIR}/libs -l_initd.lib ")"
howevery, "?" not printed, and __builtin_cpu_supports always return false in main.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions