Skip to contentSkip to conversation

s390 depending on cc-options makes it difficult to configure

DISCUSSION Jeremy Cline 4 participants 9 messages Dec 9, 2019 – Feb 18, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

Regards,
Jeremy

#1 lore raw
Quoted 12 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

Quoted 6 lines

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

This would be perhaps even easier if we also separated the environment descripton into a different file so that we would only need an option telling scripts/kconfig/conf not to update the environment description. I'm not sure if that would be acceptable for upstream, though.

Unfortunately I didn't find time to implement this yet.

Michal Kubecek

#2 lore raw
Quoted 20 lines · Michal Kubecek
Quoted 12 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

Quoted 6 lines

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 5 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

Glad (or sad?) to hear we're not the only ones hitting this.

Quoted 8 lines

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

- Jeremy

#3 lore raw

Hey Jeremy,
Hey Michal,

sorry for the late response. The mail got lost in the pre-xmas rush...

In my opinion the problem goes beyond s390 and the commit you mentioned. So I'm also adding Masahiro as Kconfig maintainer and author of cc-option.

Quoted 21 lines · On Wed, 11 Dec 2019 12:18:22 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 20 lines · Michal Kubecek
Quoted 18 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 8 lines
Quoted 8 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

If I recall correct the goal was to avoid trouble with clang, as it does not support all processor types with -march. But yeah, in the original consideration we only thought about upstream development and forgot the distros.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

True, but not the whole story. Power and Arm64 use cc-option to check for -mstack-protector*, which do not exist on s390. So you have the same problem when you prepare a config for any of them on s390. Thus simply reverting the commit you mentioned above does not solve the problem but merely hides one symptom. Which also means that the original problem will return over and over again in the future.

An other reason why I don't think it makes sens to revert the commit is that it would make cc-option as a whole useless. What's the benefit in having cc-option when you are not allowed to use it? Or less provocative, in which use cases is allowed to use cc-option?

Quoted 31 lines
Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

Quoted 4 lines

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

An other solution would be a "I know better" switch which simply disables cc-option for that run. That would allow the use of cc-option for upstream development and provide a simple way for distros to turn it off.

Quoted 7 lines

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

I too would prefer to have a warning instead of the config being silently changed. But again, the problem goes beyond what was reported.

@Masahiro: What do you think about it?

Thanks
Philipp

#4 lore raw

Hi.

Quoted 8 lines · Philipp Rudo

Hey Jeremy,
Hey Michal,

sorry for the late response. The mail got lost in the pre-xmas rush...

In my opinion the problem goes beyond s390 and the commit you mentioned. So I'm also adding Masahiro as Kconfig maintainer and author of cc-option.

I did not notice the former discussion.
Thanks for CC'ing me.

Quoted 48 lines
Quoted 21 lines · On Wed, 11 Dec 2019 12:18:22 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 20 lines · Michal Kubecek
Quoted 18 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 8 lines
Quoted 8 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

If I recall correct the goal was to avoid trouble with clang, as it does not support all processor types with -march. But yeah, in the original consideration we only thought about upstream development and forgot the distros.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

True, but not the whole story. Power and Arm64 use cc-option to check for -mstack-protector*, which do not exist on s390. So you have the same problem when you prepare a config for any of them on s390. Thus simply reverting the commit you mentioned above does not solve the problem but merely hides one symptom. Which also means that the original problem will return over and over again in the future.

Quoted 4 lines

An other reason why I don't think it makes sens to revert the commit is that it would make cc-option as a whole useless. What's the benefit in having cc-option when you are not allowed to use it? Or less provocative, in which use cases is allowed to use cc-option?

You are right.
Reverting the particular s390 commit is not the solution.

Quoted 48 lines
Quoted 31 lines
Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

Quoted 4 lines

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

An other solution would be a "I know better" switch which simply disables cc-option for that run. That would allow the use of cc-option for upstream development and provide a simple way for distros to turn it off.

Quoted 7 lines

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

Quoted 8 lines

I too would prefer to have a warning instead of the config being silently changed. But again, the problem goes beyond what was reported.

@Masahiro: What do you think about it?

Thanks
Philipp

The problem for Jeremy and Michal is,
it is difficult to get a full-feature cross-compiler for every arch.

One idea to workaround this is
to use a fake script that accepts any flag,
and use it as $(CC) in Kconfig.

RFC patch is attached.

This is not a perfect solution, of course.

Evaluating the compiler in the Kconfig stage
conceptually has a conflict with the workflow
of distro maintainers.

I think the only way to solve it completely is, ultimately, go back to pre 4.18 situation. But, I am not sure if upstream people want to do it. At least, Linus was happy to do compiler-tests in Kconfig.

I already got several criticism about the
new feature in Kconfig because it broke the
workflow of distro maintainers. Sorry about that.

The idea from Michal, separation of the build environment description, would work too.
IIRC, the crosstool-ng project generates some
Kconfig files based on the environment.
In hindsight, Kconfig did not need to have cc-option
but it was how I implemented. I just thought it would be cleaner to put cc-option and the CONFIG option depending on it very close.

Anyway, comments to the attachment are appreciated.

--
Best Regards
Masahiro Yamada

From df9b379d01b0702e3baf0f3afed893f7aa07c0f4 Mon Sep 17 00:00:00 2001
From: Masahiro Yamada <[email protected]>
Date: Thu, 13 Feb 2020 21:14:02 +0900
Subject: [PATCH RFC] kbuild: add dummy toolchains to enable all cc-option etc. in
Kconfig

Usage:

  $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig

This will make most of compiler-dependent CONFIG options visible.

This is RFC. See comments in scripts/dummy-tools/gcc for details.

---
 scripts/dummy-tools/gcc     | 91 +++++++++++++++++++++++++++++++++++++
 scripts/dummy-tools/ld      |  4 ++
 scripts/dummy-tools/nm      |  4 ++
 scripts/dummy-tools/objcopy |  4 ++
 4 files changed, 103 insertions(+)
 create mode 100755 scripts/dummy-tools/gcc
 create mode 100755 scripts/dummy-tools/ld
 create mode 100755 scripts/dummy-tools/nm
 create mode 100755 scripts/dummy-tools/objcopy
scripts/dummy-tools/gcc new file +91 -0
new file mode 100755
index 000000000000..b0f1a9c55497
@@ -0,0 +1,91 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Staring v4.18, Kconfig evaluates compiler capabilities, and hides CONFIG
+# options your compiler does not support. This works well if you configure and
+# build the kernel on the same host machine.
+#
+# It is inconvinient if you prepare the .config that is carried to a different
+# build environment (typically this happens when you package the kernel for
+# distros) because using a different compiler potentially produces different
+# CONFIG options than the real build environment. So, you probably want to make
+# as many options visible as possible. In other words, you need to create a
+# super-set of CONFIG options that cover any build environment. If some of the
+# CONFIG options turned out to be unsupported on the build machine, they are
+# automatically disabled by the nature of Kconfig.
+#
+# However, it is not feasible to get a full-featured compiler for every arch.
+# Hence these dummy toolchains to make all compiler tests pass.
+#
+# Usage:
+#
+# From the top directory of the source tree, run
+#
+#   $ make CROSS_COMPILE=scripts/dummy-tools/ oldconfig
+#
+# Most of compiler features are tested by cc-option, which simply checks the
+# exit code of $(CC). This script does nothing and just exits with 0 in most
+# cases. So, $(cc-option, ...) is evaluated as 'y'.
+#
+# This scripts caters to more checks; handle --version and pre-process __GNUC__
+# etc. to pretend to be GCC, and also do right things to satisfy some scripts.
+
+# Check if the first parameter appears in the rest. Succeeds if found.
+# This helper is useful if a particular option was passed to this script.
+# Typically used like this:
+#   arg_contain <word-you-are-searching-for> "$@"
+arg_contain ()
+{
+	search="$1"
+	shift
+
+	while [ $# -gt 0 ]
+	do
+		if [ "$search" = "$1" ]; then
+			return 0
+		fi
+		shift
+	done
+
+	return 1
+}
+
+# To set CONFIG_CC_IS_GCC=y
+if arg_contain --version "$@"; then
+	echo "gcc (scripts/dummy-tools/gcc)"
+	exit 0
+fi
+
+if arg_contain -E "$@"; then
+	# For scripts/gcc-version.sh; This emulates GCC 20.0.0
+	if arg_contain - "$@"; then
+		sed 's/^__GNUC__$/20/; s/^__GNUC_MINOR__$/0/; s/^__GNUC_PATCHLEVEL__$/0/'
+		exit 0
+	else
+		echo "no input files" >&2
+		exit 1
+	fi
+fi
+
+if arg_contain -S "$@"; then
+	# For scripts/gcc-x86-*-has-stack-protector.sh
+	if arg_contain -fstack-protector "$@"; then
+		echo "%gs"
+		exit 0
+	fi
+fi
+
+# For scripts/gcc-plugin.sh
+if arg_contain -print-file-name=plugin "$@"; then
+	plugin_dir=$(mktemp -d)
+
+	sed -n 's/.*#include "\(.*\)"/\1/p' $(dirname $0)/../gcc-plugins/gcc-common.h |
+	while read header
+	do
+		mkdir -p $plugin_dir/include/$(dirname $header)
+		touch $plugin_dir/include/$header
+	done
+
+	echo $plugin_dir
+	exit 0
+fi
scripts/dummy-tools/ld new file +4 -0
new file mode 100755
index 000000000000..3bc56ae4cc15
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+# Dummy script that always succeeds
scripts/dummy-tools/nm new file +4 -0
new file mode 100755
index 000000000000..3bc56ae4cc15
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+# Dummy script that always succeeds
scripts/dummy-tools/objcopy new file +4 -0
new file mode 100755
index 000000000000..3bc56ae4cc15
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+# Dummy script that always succeeds
Signature · 1 line
2.17.1
#5 lore raw
Quoted 130 lines · Masahiro Yamada

Hi.

Quoted 8 lines · Philipp Rudo

Hey Jeremy,
Hey Michal,

sorry for the late response. The mail got lost in the pre-xmas rush...

In my opinion the problem goes beyond s390 and the commit you mentioned. So I'm also adding Masahiro as Kconfig maintainer and author of cc-option.

I did not notice the former discussion.
Thanks for CC'ing me.

Quoted 48 lines
Quoted 21 lines · On Wed, 11 Dec 2019 12:18:22 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 20 lines · Michal Kubecek
Quoted 18 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 8 lines
Quoted 8 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

If I recall correct the goal was to avoid trouble with clang, as it does not support all processor types with -march. But yeah, in the original consideration we only thought about upstream development and forgot the distros.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

True, but not the whole story. Power and Arm64 use cc-option to check for -mstack-protector*, which do not exist on s390. So you have the same problem when you prepare a config for any of them on s390. Thus simply reverting the commit you mentioned above does not solve the problem but merely hides one symptom. Which also means that the original problem will return over and over again in the future.

Quoted 4 lines

An other reason why I don't think it makes sens to revert the commit is that it would make cc-option as a whole useless. What's the benefit in having cc-option when you are not allowed to use it? Or less provocative, in which use cases is allowed to use cc-option?

You are right.
Reverting the particular s390 commit is not the solution.

Quoted 53 lines
Quoted 31 lines
Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

Quoted 4 lines

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

An other solution would be a "I know better" switch which simply disables cc-option for that run. That would allow the use of cc-option for upstream development and provide a simple way for distros to turn it off.

Quoted 7 lines

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

I too would prefer to have a warning instead of the config being silently changed. But again, the problem goes beyond what was reported.

@Masahiro: What do you think about it?

Quoted 9 lines
Quoted 3 lines

Thanks
Philipp

The problem for Jeremy and Michal is,
it is difficult to get a full-feature cross-compiler for every arch.

Indeed.

Quoted 8 lines

One idea to workaround this is
to use a fake script that accepts any flag,
and use it as $(CC) in Kconfig.

RFC patch is attached.

This is not a perfect solution, of course.

The attached patch doesn't looks like it'd work for what we need, although I wonder if it's easier to just check when cc-options is defined for an environment variable or something and always return y instead of calling out to $(CC) at all. Comes to the same thing, I suppose.

Quoted 11 lines

Evaluating the compiler in the Kconfig stage
conceptually has a conflict with the workflow
of distro maintainers.

I think the only way to solve it completely is, ultimately, go back to pre 4.18 situation. But, I am not sure if upstream people want to do it. At least, Linus was happy to do compiler-tests in Kconfig.

Quoted 4 lines

I already got several criticism about the
new feature in Kconfig because it broke the
workflow of distro maintainers. Sorry about that.

No worries, it's a tough balancing act between upstream users and distros. It's not caused me *that* much bother.

Quoted 11 lines

The idea from Michal, separation of the build environment description, would work too.
IIRC, the crosstool-ng project generates some
Kconfig files based on the environment.
In hindsight, Kconfig did not need to have cc-option
but it was how I implemented. I just thought it would be cleaner to put cc-option and the CONFIG option depending on it very close.

Anyway, comments to the attachment are appreciated.

I believe it would solve our problem so from that perspective, it looks good to me.

Thanks,
Jeremy

#6 lore raw
Quoted 148 lines · Jeremy Cline
Quoted 130 lines · Masahiro Yamada

Hi.

Quoted 8 lines · Philipp Rudo

Hey Jeremy,
Hey Michal,

sorry for the late response. The mail got lost in the pre-xmas rush...

In my opinion the problem goes beyond s390 and the commit you mentioned. So I'm also adding Masahiro as Kconfig maintainer and author of cc-option.

I did not notice the former discussion.
Thanks for CC'ing me.

Quoted 48 lines
Quoted 21 lines · On Wed, 11 Dec 2019 12:18:22 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 20 lines · Michal Kubecek
Quoted 18 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 8 lines
Quoted 8 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

If I recall correct the goal was to avoid trouble with clang, as it does not support all processor types with -march. But yeah, in the original consideration we only thought about upstream development and forgot the distros.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

True, but not the whole story. Power and Arm64 use cc-option to check for -mstack-protector*, which do not exist on s390. So you have the same problem when you prepare a config for any of them on s390. Thus simply reverting the commit you mentioned above does not solve the problem but merely hides one symptom. Which also means that the original problem will return over and over again in the future.

Quoted 4 lines

An other reason why I don't think it makes sens to revert the commit is that it would make cc-option as a whole useless. What's the benefit in having cc-option when you are not allowed to use it? Or less provocative, in which use cases is allowed to use cc-option?

You are right.
Reverting the particular s390 commit is not the solution.

Quoted 53 lines
Quoted 31 lines
Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

Quoted 4 lines

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

An other solution would be a "I know better" switch which simply disables cc-option for that run. That would allow the use of cc-option for upstream development and provide a simple way for distros to turn it off.

Quoted 7 lines

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

I too would prefer to have a warning instead of the config being silently changed. But again, the problem goes beyond what was reported.

@Masahiro: What do you think about it?

Quoted 9 lines
Quoted 3 lines

Thanks
Philipp

The problem for Jeremy and Michal is,
it is difficult to get a full-feature cross-compiler for every arch.

Indeed.

Quoted 4 lines

One idea to workaround this is
to use a fake script that accepts any flag,
and use it as $(CC) in Kconfig.

Quoted 6 lines
Quoted 4 lines

RFC patch is attached.

This is not a perfect solution, of course.

The attached patch doesn't looks like it'd work for what we need,

I thought turning all cc-options to y would work for what you need.

With this, you can enable CONFIG_MARCH_Z13=y and CONFIG_TUNE_Z14=y instead of CONFIG_TUNE_DEFAULT.

If this approach does not work for you, what is your requirement?

Quoted 4 lines

although I wonder if it's easier to just check when cc-options is defined for an environment variable or something and always return y instead of calling out to $(CC) at all. Comes to the same thing, I suppose.

The macro definition in scripts/Kconfig.include takes precedence over any environment variable.

So, if you want to hack it from the environment, you need to change the code somehow.

The scripts/dummy-tools/ approach does not change anything for the use-case in upstream.

The result is the same, of course.

Masahiro Yamada

Quoted 37 lines
Quoted 11 lines

Evaluating the compiler in the Kconfig stage
conceptually has a conflict with the workflow
of distro maintainers.

I think the only way to solve it completely is, ultimately, go back to pre 4.18 situation. But, I am not sure if upstream people want to do it. At least, Linus was happy to do compiler-tests in Kconfig.

Quoted 4 lines

I already got several criticism about the
new feature in Kconfig because it broke the
workflow of distro maintainers. Sorry about that.

No worries, it's a tough balancing act between upstream users and distros. It's not caused me *that* much bother.

Quoted 11 lines

The idea from Michal, separation of the build environment description, would work too.
IIRC, the crosstool-ng project generates some
Kconfig files based on the environment.
In hindsight, Kconfig did not need to have cc-option
but it was how I implemented. I just thought it would be cleaner to put cc-option and the CONFIG option depending on it very close.

Anyway, comments to the attachment are appreciated.

I believe it would solve our problem so from that perspective, it looks good to me.

Thanks,
Jeremy

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw
Quoted 159 lines · Masahiro Yamada
Quoted 148 lines · Jeremy Cline
Quoted 130 lines · Masahiro Yamada

Hi.

Quoted 8 lines · Philipp Rudo

Hey Jeremy,
Hey Michal,

sorry for the late response. The mail got lost in the pre-xmas rush...

In my opinion the problem goes beyond s390 and the commit you mentioned. So I'm also adding Masahiro as Kconfig maintainer and author of cc-option.

I did not notice the former discussion. Thanks for CC'ing me.

Quoted 48 lines
Quoted 21 lines · On Wed, 11 Dec 2019 12:18:22 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 20 lines · Michal Kubecek
Quoted 18 lines · Jeremy Cline

Hi folks,

Commit 5474080a3a0a ("s390/Kconfig: make use of 'depends on cc-option'") makes it difficult to produce an s390 configuration for Fedora and Red Hat kernels.

The issue is I have the following configurations:

CONFIG_MARCH_Z13=y
CONFIG_TUNE_Z14=y
# CONFIG_TUNE_DEFAULT is not set

When the configuration is prepared on a non-s390x host without a compiler with -march=z* it changes CONFIG_TUNE_DEFAULT to y which, as far as I can tell, leads to a kernel tuned for z13 instead of z14. Fedora and Red Hat build processes produce complete configurations from snippets on any available host in the build infrastructure which very frequently is *not* s390.

Quoted 8 lines
Quoted 8 lines

We have exactly the same problem. Our developers need to update config files for different architectures and different kernel versions on their machines which are usually x86_64 but that often produces different configs than the real build environment.

This is not an issue for upstream development as one usually updates configs on the same system where the build takes place but it's a big problem for distribution maintainers.

If I recall correct the goal was to avoid trouble with clang, as it does not support all processor types with -march. But yeah, in the original consideration we only thought about upstream development and forgot the distros.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I did a quick search and couldn't find any other examples of Kconfigs depending on march or mtune compiler flags and it seems like it'd generally problematic for people preparing configurations.

True, but not the whole story. Power and Arm64 use cc-option to check for -mstack-protector*, which do not exist on s390. So you have the same problem when you prepare a config for any of them on s390. Thus simply reverting the commit you mentioned above does not solve the problem but merely hides one symptom. Which also means that the original problem will return over and over again in the future.

Quoted 4 lines

An other reason why I don't think it makes sens to revert the commit is that it would make cc-option as a whole useless. What's the benefit in having cc-option when you are not allowed to use it? Or less provocative, in which use cases is allowed to use cc-option?

You are right.
Reverting the particular s390 commit is not the solution.

Quoted 53 lines
Quoted 31 lines
Quoted 7 lines

There are more issues like this. In general, since 4.17 or 4.18, the resulting config depends on both architecture and compiler version. Earlier, you could simply run "ARCH=... make oldconfig" (or menuconfig) to update configs for all architectures and distribution versions. Today, you need to use the right compiler version (results with e.g. 4.8, 7.4 and 9.2 differ) and architecture.

Yeah, that's also troublesome. This is by no means the first problem related to the environment at configuration time, but it the most bothersome to work around (at least for Fedora kernel configuration).

Quoted 10 lines

At the moment, I'm working around the issue by using chroot environments with target distributions (e.g. openSUSE Tumbleweed) and set of cross compilers for supported architectures but it's far from perfect and even this way, there are problemantic points, e.g. BPFILTER_UMH which depends on gcc being able to not only compile but also link.

IMHO the key problem is that .config mixes configuration with description of build environment. I have an idea of a solution which would consist of

Quoted 8 lines

- an option to extract "config" options which describe build environment (i.e. their values are determined by running some command, rather than reading from a file or asking user) into a cache file
- an option telling "make *config" to use such cache file for these environment "config" options instead of running the test scripts (and probably issue an error if an environment option is missing)

Quoted 4 lines

I agree that the issue is mixing kernel configuration with build environment. I suppose a cache file would work, but it still sounds like a difficult process that is working around that fact that folks are coupling the configuration step with the build step.

An other solution would be a "I know better" switch which simply disables cc-option for that run. That would allow the use of cc-option for upstream development and provide a simple way for distros to turn it off.

Quoted 7 lines

I would advocate that this patch be reverted and an effort made to not mix build environment checks into the configuration. I'm much happier for the build to fail because the configuration can't be satisfied by the environment than I am for the configuration to quietly change or for the tools to not allow me to make the configuration in the first place. Ideally the tools would warn the user if their environment won't build the configuration, but that's a nice-to-have.

I too would prefer to have a warning instead of the config being silently changed. But again, the problem goes beyond what was reported.

@Masahiro: What do you think about it?

Quoted 9 lines
Quoted 3 lines

Thanks
Philipp

The problem for Jeremy and Michal is,
it is difficult to get a full-feature cross-compiler for every arch.

Indeed.

Quoted 4 lines

One idea to workaround this is
to use a fake script that accepts any flag, and use it as $(CC) in Kconfig.

Quoted 6 lines
Quoted 4 lines

RFC patch is attached.

This is not a perfect solution, of course.

The attached patch doesn't looks like it'd work for what we need,

I thought turning all cc-options to y would work for what you need.

Quoted 7 lines

With this, you can enable CONFIG_MARCH_Z13=y and CONFIG_TUNE_Z14=y instead of CONFIG_TUNE_DEFAULT.

If this approach does not work for you, what is your requirement?

Oof, this was an awful typo. It *would* work for what we need. Sorry for the confusion :(.

Quoted 11 lines
Quoted 6 lines

although I wonder if it's easier to just check when cc-options is defined for an environment variable or something and always return y instead of calling out to $(CC) at all. Comes to the same thing, I suppose.

The macro definition in scripts/Kconfig.include takes precedence over any environment variable.

Quoted 8 lines

So, if you want to hack it from the environment, you need to change the code somehow.

The scripts/dummy-tools/ approach does not change anything for the use-case in upstream.

The result is the same, of course.

Indeed. Since I'm not maintaining it I don't have a particularly strong opinion about the approach. Whatever you like most works for me.

- Jeremy

#8 lore raw

Hi Masahiro,

Quoted 7 lines · On Sun, 16 Feb 2020 13:57:59 -0500 Jeremy Cline <[email protected]> wrote:
Quoted 6 lines · Masahiro Yamada
Quoted 5 lines · Jeremy Cline
Quoted 3 lines · Masahiro Yamada

Hi.

On Tue, Feb 11, 2020 at 3:49 AM Philipp Rudo <[email protected]> wrote:

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

One idea to workaround this is
to use a fake script that accepts any flag,
and use it as $(CC) in Kconfig.

RFC patch is attached.

This is not a perfect solution, of course.

I like the approach as it gives both sides what they need without blowing up Kconfig.

Quoted 30 lines
Quoted 5 lines
Quoted 1 line

The attached patch doesn't looks like it'd work for what we need,

I thought turning all cc-options to y would work for what you need.

Quoted 7 lines

With this, you can enable CONFIG_MARCH_Z13=y and CONFIG_TUNE_Z14=y instead of CONFIG_TUNE_DEFAULT.

If this approach does not work for you, what is your requirement?

Oof, this was an awful typo. It *would* work for what we need. Sorry for the confusion :(.

Quoted 14 lines
Quoted 6 lines

although I wonder if it's easier to just check when cc-options is defined for an environment variable or something and always return y instead of calling out to $(CC) at all. Comes to the same thing, I suppose.

The macro definition in scripts/Kconfig.include takes precedence over any environment variable.

So, if you want to hack it from the environment, you need to change the code somehow.

Quoted 8 lines
Quoted 5 lines

The scripts/dummy-tools/ approach does not change anything for the use-case in upstream.

The result is the same, of course.

Indeed. Since I'm not maintaining it I don't have a particularly strong opinion about the approach. Whatever you like most works for me.

I agree with Jeremy. Just pick what you think is best.

Thanks a lot
Philipp