Skip to contentSkip to conversation

mk: fix make defconfig on FreeBSD

PATCH Superseded David Hunt 3 participants 9 messages Apr 10, 2018 – Apr 23, 2018

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 mk: fix make defconfig on FreeBSD

Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")
---
 mk/rte.sdkconfig.mk | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
mk/rte.sdkconfig.mk +15 -4
index 0664725ee..7b1684375 100644
@@ -36,6 +36,7 @@ notemplate:
 	@echo "use T=template from the following list:"
 	@$(MAKE) -rR showconfigs | sed 's,^,  ,'
 
+compiler:=$(filter clang gcc icc cc,$(shell ${CC} --version))
 
 .PHONY: defconfig
 defconfig:
@@ -47,15 +48,25 @@ defconfig:
                         print "arm-armv7a"} \
                 else if ($$0 == "ppc64") { \
                         print "ppc_64-power8"} \
+                else if ($$0 == "amd64") { \
+                        print "x86_64-native"} \
                 else { \
-                        printf "%s-native", $$0} }')-$(shell \
+                        printf "%s-native", $$0} }' \
+		)-$(shell \
                 uname | awk '{ \
                 if ($$0 == "Linux") { \
                         print "linuxapp"} \
                 else { \
-                        print "bsdapp"} }')-$(shell \
-                ${CC} -v 2>&1 | \
-                grep " version " | cut -d ' ' -f 1)
+                        print "bsdapp"} }' \
+		)-$(shell \
+		echo | awk -v compiler=${compiler} \
+		'{ \
+		if (compiler == "cc") \
+			{ print "gcc" } \
+		else \
+			{ print compiler } \
+		}' \
+		)
 
 .PHONY: config
 ifeq ($(RTE_CONFIG_TEMPLATE),)
Signature · 1 line
2.14.1
#2 lore raw
Quoted 7 lines · Thomas Monjalon

10/04/2018 17:08, David Hunt:

Quoted 3 lines
Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")

I am sorry, I have to nack because the change is not explained.

Apologies, Thomas. I have now added an explanation of what's going on on the patch and pushed up a v2.

Regards,
Dave.

author
#4 lore raw

PATCH v2 1/1 mk: fix make defconfig on FreeBSD

In reply to David Hunt

On FreeBSD, make defconfig generates the config as "defconfig_x86_64-bsdapp-", which does not resolve to any known config file.

This fix starts by introducing a 'compiler' variable which is set by executing "${CC} --version" and pulling out the name of the compiler.

On FreeBDS, we get amd64 out of "uname -m", which was not handled by the list of checks, but which now resolves to x86_64-native

The remaining code in the patch then takes ${compiler}, the "uname -m" output and assembles them all together into a valid freebsd config name, i.e. "defconfig_x86_64-native-bsdapp-clang"

Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")
---
 mk/rte.sdkconfig.mk | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
mk/rte.sdkconfig.mk +15 -4
index 0664725ee..7b1684375 100644
@@ -36,6 +36,7 @@ notemplate:
 	@echo "use T=template from the following list:"
 	@$(MAKE) -rR showconfigs | sed 's,^,  ,'
 
+compiler:=$(filter clang gcc icc cc,$(shell ${CC} --version))
 
 .PHONY: defconfig
 defconfig:
@@ -47,15 +48,25 @@ defconfig:
                         print "arm-armv7a"} \
                 else if ($$0 == "ppc64") { \
                         print "ppc_64-power8"} \
+                else if ($$0 == "amd64") { \
+                        print "x86_64-native"} \
                 else { \
-                        printf "%s-native", $$0} }')-$(shell \
+                        printf "%s-native", $$0} }' \
+		)-$(shell \
                 uname | awk '{ \
                 if ($$0 == "Linux") { \
                         print "linuxapp"} \
                 else { \
-                        print "bsdapp"} }')-$(shell \
-                ${CC} -v 2>&1 | \
-                grep " version " | cut -d ' ' -f 1)
+                        print "bsdapp"} }' \
+		)-$(shell \
+		echo | awk -v compiler=${compiler} \
+		'{ \
+		if (compiler == "cc") \
+			{ print "gcc" } \
+		else \
+			{ print compiler } \
+		}' \
+		)
 
 .PHONY: config
 ifeq ($(RTE_CONFIG_TEMPLATE),)
Signature · 1 line
2.14.1
#5 lore raw
Quoted 7 lines · David Hunt

On FreeBSD, make defconfig generates the config as "defconfig_x86_64-bsdapp-", which does not resolve to any known config file.

This fix starts by introducing a 'compiler' variable which is set by executing "${CC} --version" and pulling out the name of the compiler.

On FreeBDS,

^^ FreeBSD :)

we get amd64 out of "uname -m", which was not handled by the list

Quoted 1 line

of checks, but which now resolves to x86_64-native

Probably should end with a period?

Quoted 4 lines

The remaining code in the patch then takes ${compiler}, the "uname -m" output and assembles them all together into a valid freebsd config name, i.e. "defconfig_x86_64-native-bsdapp-clang"

Same here, end with period?

Quoted 5 lines
Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")

---

Left out my Tested-by.

Signature · 2 lines
Thanks,
Anatoly
#6 lore raw
In reply to David Hunt

10/04/2018 17:44, David Hunt:

Quoted 5 lines

On FreeBSD, make defconfig generates the config as "defconfig_x86_64-bsdapp-", which does not resolve to any known config file.

This fix starts by introducing a 'compiler' variable which is set by executing "${CC} --version" and pulling out the name of the compiler.

[...]

Quoted 1 line

+compiler:=$(filter clang gcc icc cc,$(shell ${CC} --version))

You should not invoke a shell command outside of a rule. Please try to move it inside the defconfig context.

Reason for this query?
1/ avoid polluting the rest of the makefile
2/ it breaks doc compilation

Why it breaks doc?
Because it breaks "make -R showversion" which is called in doc/guides/conf.py.
Tip: CC is not always defined :)

author
#7 lore raw

PATCH v3 1/1 mk: fix make defconfig on FreeBSD

In reply to David Hunt

On FreeBSD, make defconfig generates the config as "defconfig_x86_64-bsdapp-", which does not resolve to any known config file.

On FreeBSD, we get amd64 out of "uname -m", which was not handled by the list of checks, but which now resolves to x86_64-native.

Then we run '$CC --version', and use grep -o with the list of known compilers, and set to either gcc, icc or clang. Grep's '-o' option returns the matched word rather than the whole line, making the result easier to use.

The remaining code in the patch then takes ${compiler}, the "uname -m" output and assembles them all together into a valid freebsd config name, i.e. "defconfig_x86_64-native-bsdapp-clang".

v3 fixes:
Removed the call to $CC outside of the defconfig rule. No longer breaks the 'make -R showversion'. Simplified working out the compiler name using grep -o.

Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")
---
 mk/rte.sdkconfig.mk | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
mk/rte.sdkconfig.mk +14 -5
index 0664725ee..d90d62cc6 100644
@@ -36,7 +36,6 @@ notemplate:
 	@echo "use T=template from the following list:"
 	@$(MAKE) -rR showconfigs | sed 's,^,  ,'
 
-
 .PHONY: defconfig
 defconfig:
 	@$(MAKE) config T=$(shell \
@@ -47,15 +46,25 @@ defconfig:
                         print "arm-armv7a"} \
                 else if ($$0 == "ppc64") { \
                         print "ppc_64-power8"} \
+                else if ($$0 == "amd64") { \
+                        print "x86_64-native"} \
                 else { \
-                        printf "%s-native", $$0} }')-$(shell \
+                        printf "%s-native", $$0} }' \
+		)-$(shell \
                 uname | awk '{ \
                 if ($$0 == "Linux") { \
                         print "linuxapp"} \
                 else { \
-                        print "bsdapp"} }')-$(shell \
-                ${CC} -v 2>&1 | \
-                grep " version " | cut -d ' ' -f 1)
+                        print "bsdapp"} }' \
+		)-$(shell \
+		${CC} --version | grep -o 'cc\|gcc\|icc\|clang' | awk \
+		'{ \
+		if ($$1 == "cc") { \
+			print "gcc" } \
+		else { \
+			print $$1 } \
+		}' \
+		)
 
 .PHONY: config
 ifeq ($(RTE_CONFIG_TEMPLATE),)
Signature · 1 line
2.14.1
#8 lore raw

23/04/2018 15:09, David Hunt:

Quoted 21 lines

On FreeBSD, make defconfig generates the config as "defconfig_x86_64-bsdapp-", which does not resolve to any known config file.

On FreeBSD, we get amd64 out of "uname -m", which was not handled by the list of checks, but which now resolves to x86_64-native.

Then we run '$CC --version', and use grep -o with the list of known compilers, and set to either gcc, icc or clang. Grep's '-o' option returns the matched word rather than the whole line, making the result easier to use.

The remaining code in the patch then takes ${compiler}, the "uname -m" output and assembles them all together into a valid freebsd config name, i.e. "defconfig_x86_64-native-bsdapp-clang".

v3 fixes:
Removed the call to $CC outside of the defconfig rule. No longer breaks the 'make -R showversion'. Simplified working out the compiler name using grep -o.

Quoted 4 lines
Fixes bce6c42c4ad5 ("mk: add sensible default target with defconfig")

Applied, thanks