mesonbuild / meson

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

Linker detection fails for wr-cc (VxWorks) without a file input #13218

Open petwu opened 1 month ago

petwu commented 1 month ago

Describe the bug I wanted to build fribidi for VxWorks via the respective conan recipe. Unfortunately, the configure step failed with the following error:

Detecting linker via: `wr-cc -Wl,--version` -> 0

..\src\meson.build:1:0: ERROR: Unable to detect linker for compiler `wr-cc -Wl,--version`
stdout: 
stderr: 

The problem is, that without a file argument (actually, any string will do, it doesn't need to be the path to an existing file), the command just exits without printing anything. See the difference:

C:\VxWorks\V7.2303>wr-cc -Wl,--version

C:\VxWorks\V7.2303>wr-cc -Wl,--version foo
GNU ld (GNU Binutils) 2.40
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

To Reproduce Any hello-world project will do. Though, I'm afraid VxWorks is proprietary and paid, which may limit testability on your side. So I am happy to help out if you need any testing done.

Expected behavior I have noticed, that for some compilers you already pass a dummy file path when detecting the linker version (see here, here, here and here). Doing something similar for the wr-cc/wr-c++ compiler would solve the issue.

As this requirement to pass a file seems somewhat common across different compilers/linkers, maybe you could implement the linker detection with a fallback, that adds a file path argument to the command if the detection without fails. This way it would be linker-agnostic and would not require handling every special case out there. Just a suggestion.

system parameters