mesonbuild / meson

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

Name clash bug #8752

Open Volker-Weissmann opened 3 years ago

Volker-Weissmann commented 3 years ago

Describe the bug If a target has the same name as a sub directory, attempting to build will output

/usr/local/bin/ld: cannot open output file $directoryname: Is a directory

To Reproduce

Download bug.zip or create it as follows:

$ tree
.
├── clash
│   ├── lib.cpp
│   └── meson.build
├── main.cpp
└── meson.build

meson.build:

project('Bug', 'cpp')
subdir('clash')
executable('clash', 'main.cpp')

clash/meson.build:

library('irrelevant', 'lib.cpp')

main.cpp and lib.cpp are simple nearly empty, valid C++ files.

$ meson setup build
...
$ meson compile -C build
ninja: Entering directory `build'
[3/4] Linking target clash
FAILED: clash 
c++  -o clash clash.p/main.cpp.o -Wl,--as-needed -Wl,--no-undefined
/usr/local/bin/ld: cannot open output file clash: Is a directory
collect2: error: ld returned 1 exit status
[4/4] Linking target clash/libirrelevant.so
ninja: build stopped: subcommand failed.

system parameters

eli-schwartz commented 3 years ago

This would be an error for any build system, I imagine. Granted, it would be preferable to error out during setup rather than during build.

I will note, however, that meson setup builddir --layout flat actually works quite well here and is even intended for this use case. Although in the general case it tends to break if your targets clash rather than your directory layouts. ;)

Volker-Weissmann commented 3 years ago

This would be an error for any build system, I imagine.

Not if you do some name-mangeling. (Altough I'm not sure if this would be a good idea.)

Granted, it would be preferable to error out during setup rather than during build.

Absolutely.

meson setup builddir --layout flat actually works quite well here

The Problem is that --layout flat is global, so if you have a nameclash in the flat layout somewhere else, you are stuck.

eli-schwartz commented 3 years ago

Not if you do some name-mangeling. (Altough I'm not sure if this would be a good idea.)

Probably not :) e.g. I'm highly dependent on the --layout mirror to preserve directory hierarchy so that an application can run uninstalled from the build tree for testing.

The Problem is that --layout flat is global, so if you have a nameclash in the flat layout somewhere else, you are stuck.

I did mention that in the next sentence, yes.

tristan957 commented 1 year ago

@eli-schwartz is there any actionable thing here?