Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects of files() may be ambiguous #1494

Closed
codido opened this issue Mar 23, 2017 · 5 comments
Closed

Objects of files() may be ambiguous #1494

codido opened this issue Mar 23, 2017 · 5 comments
Labels

Comments

@codido
Copy link

codido commented Mar 23, 2017

When files are specified using files(), their subdirectories aren't added as a prefix to their object file names, and all are output to the same output directory. As a result, if two different subdirectories have files with the same name, a conflict will follow.

For example, the following fails with Multiple producers for Ninja target "a.out@exe/file.c.o". Please rename your targets.:

#!/bin/sh

mkdir -p dir1 dir2

echo "int main() { return 0; }" > dir1/file.c
echo "sources += files('file.c')" > dir1/meson.build

touch dir2/file.c
echo "sources += files('file.c')" > dir2/meson.build

cat >meson.build <<EOF
project('proj', 'c')

sources = []
subdir('dir1')
subdir('dir2')
executable('a.out', sources: sources)
EOF

meson build
@nirbheek nirbheek added the bug label Mar 23, 2017
@nirbheek
Copy link
Member

The fix for this is to use not the filename for deriving the object name, but the relative path to the current directory. The fix will have to also keep into account object extraction.

@codido
Copy link
Author

codido commented Mar 24, 2017

@nirbheek Semi-related to this, perhaps extract_objects() should be able to receive files() as arguments?

@nirbheek
Copy link
Member

Yes, that makes sense too!

QuLogic added a commit to QuLogic/meson that referenced this issue Jun 14, 2017
Also, check a file with a subdirectory and extract_objects().
QuLogic added a commit to QuLogic/meson that referenced this issue Jun 14, 2017
This prevents files with the same name from different directories from
producing object files with the same name and breaking ninja.

Fixes mesonbuild#1494.
QuLogic added a commit to QuLogic/meson that referenced this issue Jun 14, 2017
This prevents files with the same name from different directories from
producing object files with the same name and breaking ninja.

Fixes mesonbuild#1494.
QuLogic added a commit to QuLogic/meson that referenced this issue Jun 22, 2017
Also, check a file with a subdirectory and extract_objects().
QuLogic added a commit to QuLogic/meson that referenced this issue Jun 22, 2017
This prevents files with the same name from different directories from
producing object files with the same name and breaking ninja.

Fixes mesonbuild#1494.
QuLogic added a commit to QuLogic/meson that referenced this issue Jul 5, 2017
Also, check a file with a subdirectory and extract_objects().
QuLogic added a commit to QuLogic/meson that referenced this issue Jul 5, 2017
This prevents files with the same name from different directories from
producing object files with the same name and breaking ninja.

Fixes mesonbuild#1494.
@kaimast
Copy link

kaimast commented Aug 9, 2017

Is there a way to hack around this in earlier versions of meson?

@nirbheek
Copy link
Member

nirbheek commented Aug 9, 2017

If you can't rename the files, you can hack around it by 'copying' the files into the build directory with configure_file():

copied_file = configure_file(input : 'source-file.c',
  output : 'renamed-file.c',
  configuration : configuration_data())

Then use the copied_file variable instead of 'source-file.c' everywhere.

QuLogic added a commit to QuLogic/meson that referenced this issue Aug 14, 2017
Also, check a file with a subdirectory and extract_objects().
QuLogic added a commit to QuLogic/meson that referenced this issue Aug 14, 2017
This prevents files with the same name from different directories from
producing object files with the same name and breaking ninja.

Fixes mesonbuild#1494.
QuLogic added a commit to QuLogic/meson that referenced this issue Aug 15, 2017
Also, check a file with a subdirectory and extract_objects().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants