diff mbox

[2/3] Config.in: add symbols for BR2_HOST_GCC_AT_LEAST_X_Y

Message ID 1448147919-5463-2-git-send-email-arnout@mind.be
State Changes Requested
Headers show

Commit Message

Arnout Vandecappelle Nov. 21, 2015, 11:18 p.m. UTC
Some host packages need a recent gcc version. Add symbols to Config.in
to specify the HOSTCC version. The values are passed through the
environment, and this environment is generated in a new support script.

Also update the documentation to mention the new symbols.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 Config.in                                 | 17 ++++++++++
 Makefile                                  |  1 +
 docs/manual/adding-packages-directory.txt |  7 ++++
 support/scripts/gcc-version-variables     | 56 +++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100755 support/scripts/gcc-version-variables

Comments

Yann E. MORIN Nov. 29, 2015, 5:48 p.m. UTC | #1
Arnout, All,

On 2015-11-22 00:18 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
> Some host packages need a recent gcc version. Add symbols to Config.in
> to specify the HOSTCC version. The values are passed through the
> environment, and this environment is generated in a new support script.

I really don't like this...

Maybe it is a good candidate for a generated kconfig snippet, instead of
this generated-environment oddity?

Anyway, see below, you could generate only one environment variable,
instead of all of them...

> Also update the documentation to mention the new symbols.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> ---
>  Config.in                                 | 17 ++++++++++
>  Makefile                                  |  1 +
>  docs/manual/adding-packages-directory.txt |  7 ++++
>  support/scripts/gcc-version-variables     | 56 +++++++++++++++++++++++++++++++
>  4 files changed, 81 insertions(+)
>  create mode 100755 support/scripts/gcc-version-variables
> 
> diff --git a/Config.in b/Config.in
> index d795361..7bec90c 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -18,6 +18,23 @@ config BR2_EXTERNAL
>  	string
>  	option env="BR2_EXTERNAL"
>  
> +# Hidden config symbols for packages to check system gcc version
> +config BR2_HOST_GCC_AT_LEAST_4_7
> +	bool
> +	option env="HOST_GCC_AT_LEAST_4_7"
> +
> +config BR2_HOST_GCC_AT_LEAST_4_8
> +	bool
> +	option env="HOST_GCC_AT_LEAST_4_8"
> +
> +config BR2_HOST_GCC_AT_LEAST_4_9
> +	bool
> +	option env="HOST_GCC_AT_LEAST_4_9"
> +
> +config BR2_HOST_GCC_AT_LEAST_5
> +	bool
> +	option env="HOST_GCC_AT_LEAST_5"

If you make each of those options actually select the N-1 option, then
all you need if to set one environment variable.

[--SNIP--]
> diff --git a/docs/manual/adding-packages-directory.txt b/docs/manual/adding-packages-directory.txt
> index 139123e..c2d9f75 100644
> --- a/docs/manual/adding-packages-directory.txt
> +++ b/docs/manual/adding-packages-directory.txt
> @@ -283,6 +283,13 @@ use in the comment.
>  ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
>     +X.Y+ with the proper version)
>  
> +* Host GCC version
> +** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
> +   +X_Y+ with the proper version, see +Config.in+)
> +** Comment string: no comment to be added
> +** Note that it is usually not the package itself that has a minimum
> +   host GCC version, but rather a host-package on which it depends.

Well, in case the package builds an internal host tool, and properly
separates BUILD_CC from CC, then the restriction does apply to the
package itself and not a host-package.

Regards,
Yann E. MORIN.
Arnout Vandecappelle Nov. 29, 2015, 8:55 p.m. UTC | #2
On 29-11-15 18:48, Yann E. MORIN wrote:
> Arnout, All,
> 
> On 2015-11-22 00:18 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
>> Some host packages need a recent gcc version. Add symbols to Config.in
>> to specify the HOSTCC version. The values are passed through the
>> environment, and this environment is generated in a new support script.
> 
> I really don't like this...

 I originally had it as a make fragment :-P

> 
> Maybe it is a good candidate for a generated kconfig snippet, instead of
> this generated-environment oddity?

 I never thought of that, it would be a possibility. If I would have time :-)
I'd have a go at it.

> 
> Anyway, see below, you could generate only one environment variable,
> instead of all of them...
> 
>> Also update the documentation to mention the new symbols.
>>
>> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
>> ---
>>  Config.in                                 | 17 ++++++++++
>>  Makefile                                  |  1 +
>>  docs/manual/adding-packages-directory.txt |  7 ++++
>>  support/scripts/gcc-version-variables     | 56 +++++++++++++++++++++++++++++++
>>  4 files changed, 81 insertions(+)
>>  create mode 100755 support/scripts/gcc-version-variables
>>
>> diff --git a/Config.in b/Config.in
>> index d795361..7bec90c 100644
>> --- a/Config.in
>> +++ b/Config.in
>> @@ -18,6 +18,23 @@ config BR2_EXTERNAL
>>  	string
>>  	option env="BR2_EXTERNAL"
>>  
>> +# Hidden config symbols for packages to check system gcc version
>> +config BR2_HOST_GCC_AT_LEAST_4_7
>> +	bool
>> +	option env="HOST_GCC_AT_LEAST_4_7"
>> +
>> +config BR2_HOST_GCC_AT_LEAST_4_8
>> +	bool
>> +	option env="HOST_GCC_AT_LEAST_4_8"
>> +
>> +config BR2_HOST_GCC_AT_LEAST_4_9
>> +	bool
>> +	option env="HOST_GCC_AT_LEAST_4_9"
>> +
>> +config BR2_HOST_GCC_AT_LEAST_5
>> +	bool
>> +	option env="HOST_GCC_AT_LEAST_5"
> 
> If you make each of those options actually select the N-1 option, then
> all you need if to set one environment variable.

 Alas, that is not possible with the env option. You'd need two symbols, one for
getting it from the environment and a real one that can be selected.

> 
> [--SNIP--]
>> diff --git a/docs/manual/adding-packages-directory.txt b/docs/manual/adding-packages-directory.txt
>> index 139123e..c2d9f75 100644
>> --- a/docs/manual/adding-packages-directory.txt
>> +++ b/docs/manual/adding-packages-directory.txt
>> @@ -283,6 +283,13 @@ use in the comment.
>>  ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
>>     +X.Y+ with the proper version)
>>  
>> +* Host GCC version
>> +** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
>> +   +X_Y+ with the proper version, see +Config.in+)
>> +** Comment string: no comment to be added
>> +** Note that it is usually not the package itself that has a minimum
>> +   host GCC version, but rather a host-package on which it depends.
> 
> Well, in case the package builds an internal host tool, and properly
> separates BUILD_CC from CC, then the restriction does apply to the
> package itself and not a host-package.

 Yeah I know, however it's complicated to explain that well in the manual, and I
don't believe it will ever happen in practice. Things built with BUILD_CC are
usually pretty simple tools.


 Regards,
 Arnout

> 
> Regards,
> Yann E. MORIN.
>
Yann E. MORIN Nov. 29, 2015, 9:14 p.m. UTC | #3
Arnout, All,

On 2015-11-29 21:55 +0100, Arnout Vandecappelle spake thusly:
> On 29-11-15 18:48, Yann E. MORIN wrote:
> > Arnout, All,
> > 
> > On 2015-11-22 00:18 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
> >> Some host packages need a recent gcc version. Add symbols to Config.in
> >> to specify the HOSTCC version. The values are passed through the
> >> environment, and this environment is generated in a new support script.
> > 
> > I really don't like this...
> 
>  I originally had it as a make fragment :-P
> 
> > 
> > Maybe it is a good candidate for a generated kconfig snippet, instead of
> > this generated-environment oddity?
> 
>  I never thought of that, it would be a possibility. If I would have time :-)
> I'd have a go at it.

I already have all that is needed to generate a kconfig fragment, in my
multi br2-external series.

It was meant only as a mean to add the generated Config.in that
aggregates all the br2-external entries, but otherwise adds all the
dependencies in the Makefile to ensure the fragment is created before we
run any kconfig program.

So, if you could review those patches, we can get them early (if not the
complete series) so all you'd have is to write the kconfig snippet
generator for the host gcc version checks.

[--SNIP--]
> >> +# Hidden config symbols for packages to check system gcc version
> >> +config BR2_HOST_GCC_AT_LEAST_4_7
> >> +	bool
> >> +	option env="HOST_GCC_AT_LEAST_4_7"
> >> +
> >> +config BR2_HOST_GCC_AT_LEAST_4_8
> >> +	bool
> >> +	option env="HOST_GCC_AT_LEAST_4_8"
> >> +
> >> +config BR2_HOST_GCC_AT_LEAST_4_9
> >> +	bool
> >> +	option env="HOST_GCC_AT_LEAST_4_9"
> >> +
> >> +config BR2_HOST_GCC_AT_LEAST_5
> >> +	bool
> >> +	option env="HOST_GCC_AT_LEAST_5"
> > 
> > If you make each of those options actually select the N-1 option, then
> > all you need if to set one environment variable.
> 
>  Alas, that is not possible with the env option. You'd need two symbols, one for
> getting it from the environment and a real one that can be selected.

That's not what I conclude from my experiments:

    $ cat env-select.in
    comment "What is enabled?"
    config FOO
        bool
        option env="KCFG_FOO"
    config BAR
        bool
        select FOO
        option env="KCFG_BAR"
    comment "FOO=y"
        depends on FOO
    comment "BAR=y"
        depends on BAR

    $ KCFG_BAR=y mconf env-select.in
    *** What is enabled? ***
    *** FOO=y ***
    *** BAR=y ***

So, it seems BAR does indeed select FOO, no? ;-)

[--SNIP--]
> >> +* Host GCC version
> >> +** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
> >> +   +X_Y+ with the proper version, see +Config.in+)
> >> +** Comment string: no comment to be added
> >> +** Note that it is usually not the package itself that has a minimum
> >> +   host GCC version, but rather a host-package on which it depends.
> > 
> > Well, in case the package builds an internal host tool, and properly
> > separates BUILD_CC from CC, then the restriction does apply to the
> > package itself and not a host-package.
> 
>  Yeah I know, however it's complicated to explain that well in the manual, and I
> don't believe it will ever happen in practice. Things built with BUILD_CC are
> usually pretty simple tools.

Agreed.

Regards,
Yann E. MORIN.
Arnout Vandecappelle Nov. 29, 2015, 9:41 p.m. UTC | #4
On 29-11-15 22:14, Yann E. MORIN wrote:
> Arnout, All,
> 
> On 2015-11-29 21:55 +0100, Arnout Vandecappelle spake thusly:
>> On 29-11-15 18:48, Yann E. MORIN wrote:
>>> Arnout, All,
>>>
>>> On 2015-11-22 00:18 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
>>>> Some host packages need a recent gcc version. Add symbols to Config.in
>>>> to specify the HOSTCC version. The values are passed through the
>>>> environment, and this environment is generated in a new support script.
>>>
>>> I really don't like this...
>>
>>  I originally had it as a make fragment :-P
>>
>>>
>>> Maybe it is a good candidate for a generated kconfig snippet, instead of
>>> this generated-environment oddity?
>>
>>  I never thought of that, it would be a possibility. If I would have time :-)
>> I'd have a go at it.
> 
> I already have all that is needed to generate a kconfig fragment, in my
> multi br2-external series.

> 
> It was meant only as a mean to add the generated Config.in that
> aggregates all the br2-external entries, but otherwise adds all the
> dependencies in the Makefile to ensure the fragment is created before we
> run any kconfig program.
> 
> So, if you could review those patches, we can get them early (if not the
> complete series) so all you'd have is to write the kconfig snippet
> generator for the host gcc version checks.

 I'll try to do that.

> 
> [--SNIP--]
>>>> +# Hidden config symbols for packages to check system gcc version
>>>> +config BR2_HOST_GCC_AT_LEAST_4_7
>>>> +	bool
>>>> +	option env="HOST_GCC_AT_LEAST_4_7"
>>>> +
>>>> +config BR2_HOST_GCC_AT_LEAST_4_8
>>>> +	bool
>>>> +	option env="HOST_GCC_AT_LEAST_4_8"
>>>> +
>>>> +config BR2_HOST_GCC_AT_LEAST_4_9
>>>> +	bool
>>>> +	option env="HOST_GCC_AT_LEAST_4_9"
>>>> +
>>>> +config BR2_HOST_GCC_AT_LEAST_5
>>>> +	bool
>>>> +	option env="HOST_GCC_AT_LEAST_5"
>>>
>>> If you make each of those options actually select the N-1 option, then
>>> all you need if to set one environment variable.
>>
>>  Alas, that is not possible with the env option. You'd need two symbols, one for
>> getting it from the environment and a real one that can be selected.
> 
> That's not what I conclude from my experiments:
> 
>     $ cat env-select.in
>     comment "What is enabled?"
>     config FOO
>         bool
>         option env="KCFG_FOO"
>     config BAR
>         bool
>         select FOO
>         option env="KCFG_BAR"
>     comment "FOO=y"
>         depends on FOO
>     comment "BAR=y"
>         depends on BAR
> 
>     $ KCFG_BAR=y mconf env-select.in
>     *** What is enabled? ***
>     *** FOO=y ***
>     *** BAR=y ***
> 
> So, it seems BAR does indeed select FOO, no? ;-)

 OK, I just remembered something like that from experiments with LEGACY and
didn't try again. I guess I remembered incorrectly :-)


 Regards,
 Arnout

> 
> [--SNIP--]
>>>> +* Host GCC version
>>>> +** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
>>>> +   +X_Y+ with the proper version, see +Config.in+)
>>>> +** Comment string: no comment to be added
>>>> +** Note that it is usually not the package itself that has a minimum
>>>> +   host GCC version, but rather a host-package on which it depends.
>>>
>>> Well, in case the package builds an internal host tool, and properly
>>> separates BUILD_CC from CC, then the restriction does apply to the
>>> package itself and not a host-package.
>>
>>  Yeah I know, however it's complicated to explain that well in the manual, and I
>> don't believe it will ever happen in practice. Things built with BUILD_CC are
>> usually pretty simple tools.
> 
> Agreed.
> 
> Regards,
> Yann E. MORIN.
>
Yann E. MORIN Nov. 29, 2015, 9:53 p.m. UTC | #5
Arnout, All,

On 2015-11-29 22:41 +0100, Arnout Vandecappelle spake thusly:
> On 29-11-15 22:14, Yann E. MORIN wrote:
> > On 2015-11-29 21:55 +0100, Arnout Vandecappelle spake thusly:
> >> On 29-11-15 18:48, Yann E. MORIN wrote:
[--SNIP--]
> >>> If you make each of those options actually select the N-1 option, then
> >>> all you need if to set one environment variable.
> >>  Alas, that is not possible with the env option. You'd need two symbols, one for
> >> getting it from the environment and a real one that can be selected.
> > That's not what I conclude from my experiments:
[--SNIP--]
>  OK, I just remembered something like that from experiments with LEGACY and
> didn't try again. I guess I remembered incorrectly :-)

What is sure is that those symbols are not saved in .config .

Not sure how legacy would have been impacted by the env option,
though...

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/Config.in b/Config.in
index d795361..7bec90c 100644
--- a/Config.in
+++ b/Config.in
@@ -18,6 +18,23 @@  config BR2_EXTERNAL
 	string
 	option env="BR2_EXTERNAL"
 
+# Hidden config symbols for packages to check system gcc version
+config BR2_HOST_GCC_AT_LEAST_4_7
+	bool
+	option env="HOST_GCC_AT_LEAST_4_7"
+
+config BR2_HOST_GCC_AT_LEAST_4_8
+	bool
+	option env="HOST_GCC_AT_LEAST_4_8"
+
+config BR2_HOST_GCC_AT_LEAST_4_9
+	bool
+	option env="HOST_GCC_AT_LEAST_4_9"
+
+config BR2_HOST_GCC_AT_LEAST_5
+	bool
+	option env="HOST_GCC_AT_LEAST_5"
+
 # Hidden boolean selected by packages in need of Java in order to build
 # (example: xbmc)
 config BR2_NEEDS_HOST_JAVA
diff --git a/Makefile b/Makefile
index 76c9bff..60d9a0f 100644
--- a/Makefile
+++ b/Makefile
@@ -712,6 +712,7 @@  COMMON_CONFIG_ENV = \
 	KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
 	BR2_CONFIG=$(BR2_CONFIG) \
 	BR2_EXTERNAL=$(BR2_EXTERNAL) \
+	$(shell support/scripts/gcc-version-variables $(HOSTCC_NOCCACHE)) \
 	SKIP_LEGACY=
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
diff --git a/docs/manual/adding-packages-directory.txt b/docs/manual/adding-packages-directory.txt
index 139123e..c2d9f75 100644
--- a/docs/manual/adding-packages-directory.txt
+++ b/docs/manual/adding-packages-directory.txt
@@ -283,6 +283,13 @@  use in the comment.
 ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
    +X.Y+ with the proper version)
 
+* Host GCC version
+** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
+   +X_Y+ with the proper version, see +Config.in+)
+** Comment string: no comment to be added
+** Note that it is usually not the package itself that has a minimum
+   host GCC version, but rather a host-package on which it depends.
+
 * C library
 ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
    +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+
diff --git a/support/scripts/gcc-version-variables b/support/scripts/gcc-version-variables
new file mode 100755
index 0000000..282cfc3
--- /dev/null
+++ b/support/scripts/gcc-version-variables
@@ -0,0 +1,56 @@ 
+#! /bin/sh
+#
+# Print the environment variables for top-level Config.in's
+# HOST_GCC_AT_LEAST_X_Y. First argument is the compiler.
+#
+# Copyright (C) 2014 by the Buildroot developers <buildroot@buildroot.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+HOSTCC_NOCCACHE="$1"
+
+# hostcc version as an integer - E.G. 4.9.2 => 49
+HOSTCC_VERSION=$(${HOSTCC_NOCCACHE} --version | \
+    sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$/\1\2/p')
+
+if [ -z "$HOSTCC_VERSION" ]; then
+    printf 'Usage: %s <path-to-compiler>\n' "$0" 1>&2
+    exit 1
+fi
+
+print_host_gcc_at_least() {
+    local version
+    printf 'HOST_GCC_AT_LEAST_%s' "$1"
+    if [ "$2" ]; then
+        printf '_%s' "$2"
+        version="$1$2"
+    else
+        version="${1}0"
+    fi
+    printf '='
+
+    if [ "$HOSTCC_VERSION" -ge $version ]; then
+        printf 'y'
+    else
+        printf 'n'
+    fi
+    printf ' '
+}
+
+print_host_gcc_at_least 4 7
+print_host_gcc_at_least 4 8
+print_host_gcc_at_least 4 9
+print_host_gcc_at_least 5