mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.56k stars 1.61k forks source link

CC_LD and friends are not retained for reconfigure #12261

Open medhefgo opened 1 year ago

medhefgo commented 1 year ago
project('bug', 'c', meson_version : '>= 1.0.0')
cc = meson.get_compiler('c')
assert(cc.get_linker_id() == 'ld.gold')
assert(not cc.has_link_argument('-Wl,--no-dynamic-linker'))
$ CC_LD=gold meson setup --wipe build && meson setup --reconfigure build
The Meson build system
Version: 1.2.1
Source dir: /tmp/bug
Build dir: /tmp/bug/build
Build type: native build
Project name: bug
Project version: undefined
C compiler for the host machine: ccache cc (gcc 13.2.1 "cc (GCC) 13.2.1 20230801")
C linker for the host machine: cc ld.gold 2.41.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports link arguments -Wl,--no-dynamic-linker: NO 
Build targets in project: 0

Found ninja-1.11.1 at /usr/bin/ninja
The Meson build system                                                                                                                                                 
Version: 1.2.1
Source dir: /tmp/bug
Build dir: /tmp/bug/build
Build type: native build
Project name: bug
Project version: undefined
C compiler for the host machine: ccache cc (gcc 13.2.1 "cc (GCC) 13.2.1 20230801")
C linker for the host machine: cc ld.gold 2.41.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports link arguments -Wl,--no-dynamic-linker: YES 

meson.build:4:0: ERROR: Assert failed: not cc.has_link_argument('-Wl,--no-dynamic-linker')

A full log can be found at /tmp/bug/build/meson-logs/meson-log.txt
medhefgo commented 1 year ago

Turns out that CC_LD and friend are not stored in coredata for future reconfigure unlike CFLAGS/LDFLAGS. This causes inconsistent state where things liker cc.has_link_argument() does not get the linker flag passed, while cc.get_linker_id() and ninja code generation probably get it directly from the pickled linker object.

@dcbaker This cannot possibly be intentional behavior, no?

dcbaker commented 1 year ago

No, that's not intentional. They should be stored consistently.... We have too many copies of the same information... Sigh