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

Subproject/wrap configuration and building do not respect a consistent set of default_options #11558

Open
amyspark opened this issue Mar 20, 2023 · 0 comments

Comments

@amyspark
Copy link
Contributor

Describe the bug

Configuration and building of a subproject or dependency via wrap is being done inconsistently.

Currently, configuration and tests are done with the default options of the base project, not forwarding any options set on the default_options parameter of the corresponding dependency or subproject call. Building is done with the default options of the subproject.

Where the compilation depends on compiler or target ABI's characteristics, such as Apple's -mmacosx-minimum-ver=10.15, the compilation can fail in unpredictable ways because of the mismatch.

To Reproduce

The example below applies whether it's a subproject() or a dependency(). To test for a subproject, replace the clause with

substrate = subproject(
	'substrate',
	required: true,
	version: '>=0.0.1',
	default_options: [
		'build_tests=false',
		'cpp_std=c++17',
	]
).get_variable(
	'substrate_dep'
).partial_dependency(
	compile_args: true,
	includes: true
)

meson.build:

project(
	'test',
	'cpp',
	default_options: [
		'cpp_std=c++17',
		'warning_level=3',
		'buildtype=release',
		'strip=true',
		'b_ndebug=if-release',
		'b_lto=true'
	],
	version: '0.5.2',
	meson_version: '>= 0.56',
	subproject_dir: 'deps'
)

substrate = dependency(
	'substrate',
	required: true,
	version: '>=0.0.1',
	default_options: [
		'build_tests=false',
		'cpp_std=c++17',
	]
)

e = executable('test', 'test.cpp', dependencies: substrate)

deps/substrate.wrap:

[wrap-git]
url = https://github.com/bad-alloc-heavy-industries/substrate.git
revision = head
clone-recursive = false

[provide]
substrate = substrate_dep

test.cpp:

int main() { return 0; }

Expected behavior

Compilation to succeed. Instead, I get the following error log (elided because it's really long).

A quick introspection reveals that there's something wrong with the flags being passed. The tests' C++ standard is clearly C++17, but the build's is clearly the compiler's default (which is C++03).

❯ meson introspect --buildoptions -i | grep cpp_std -n2
686-    },
687-    {
688:        "name": "build.cpp_std",
689-        "value": "none",
690-        "section": "compiler",
--
--
750-    },
751-    {
752:        "name": "cpp_std",
753-        "value": "c++17",
754-        "section": "compiler",
--
--
890-    },
891-    {
892:        "name": "substrate:build.cpp_std",
893-        "value": "none",
894-        "section": "compiler",
--
--
938-    },
939-    {
940:        "name": "substrate:cpp_std",
941-        "value": "c++17",
942-        "section": "compiler",

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? plain native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) macOS Big Sur 11.7.4
  • what Python version are you using e.g. 3.8.0 3.11.2
  • what meson --version 1.0.1
  • what ninja --version if it's a Ninja build 1.11.1
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

No branches or pull requests

1 participant