Skip to content

Muon with clang fails to link with ubsan if b_sanitize is set to either undefined or address,undefined on shared libraries #176

@SRAZKVT

Description

@SRAZKVT

I hit this issue when trying to make a project have a library instead of just going straight to an executable, it works otherwise. After that, i tested with meson, and it works there too.

Here is a small project that reproduces the issue:

add.c:

int add(int a, int b) {
	return a + b;
}

main.c:

int add(int a, int b);

int main(void) {
	add(1, 2);
	return 0;
}

meson.build:

project(
	'bug_muon',
	'c',
	version : '0.1',
	default_options : ['warning_level=3']
)

lib_add = shared_library(
	'add',
	'add.c',
)

exe = executable(
	'main',
	'main.c',
	link_with : lib_add,
)

test('test', exe)

the commands i run are then

CC=clang muon setup -Db_sanitize=undefined -Db_lundef=false build

and

muon -C build test

this only happens with clang as far as i can see, not with GCC, and happens regardless of whether -Db_lundef is present or not

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions