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

"links" test with file argument should use the appropriate compiler for the source file #7703

Closed
bonzini opened this issue Sep 6, 2020 · 1 comment · Fixed by #9014
Closed

Comments

@bonzini
Copy link
Contributor

bonzini commented Sep 6, 2020

Describe the bug
I would like to test that the C++ driver (e.g. g++) can be used to link C objects. One usecase is that the C compiler's libsanitizer might not be compatible with the one included by the C++ driver..

However, something like meson.get_compiler('cpp').links(files('main.c')) results in the following log:

Command line:  c++ /home/pbonzini/ff/main.c -o /home/pbonzini/ff/build/meson-private/tmpa0bmxj_m/output.exe -pipe -D_FILE_OFFSET_BITS=64 -O0 -fpermissive

instead of for example:

Command line:  cc /home/pbonzini/ff/main.c -o /home/pbonzini/ff/build/meson-private/tmpa0bmxj_m/output.o -pipe -D_FILE_OFFSET_BITS=64 -O0
Command line:  c++ /home/pbonzini/ff/build/meson-private/tmpa0bmxj_m/output.o -o /home/pbonzini/ff/build/meson-private/tmpa0bmxj_m/output.exe -pipe -O0

To Reproduce

  • main.c: int main() {}
  • meson.build:
project('a', ['c', 'cpp'])
meson.get_compiler('cpp').links(files('main.c'))
@bonzini
Copy link
Contributor Author

bonzini commented Sep 6, 2020

This is theoretically backwards-incompatible, but it should be treated as a bugfix in my opinion. There's no way in Meson to compile a .c file with the C++ driver as part of a build target, therefore there would be no reason to want this configuration.

Another possibility is to add a can_link_language method to the compiler object. The two changes can be done independently.

bonzini added a commit to bonzini/meson that referenced this issue Jul 22, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
bonzini added a commit to bonzini/meson that referenced this issue Jul 22, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
bonzini added a commit to bonzini/meson that referenced this issue Jul 22, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
bonzini added a commit to bonzini/meson that referenced this issue Sep 7, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
bonzini added a commit to bonzini/meson that referenced this issue Sep 7, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
trhd pushed a commit to trhd/meson that referenced this issue Sep 29, 2021
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: mesonbuild#7703
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant