public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] Makefile, seccomp.sh: Fix cross-builds, adjust syscalls list to compiler
@ 2023-02-28 10:17 Stefano Brivio
  2023-03-01  3:24 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2023-02-28 10:17 UTC (permalink / raw)
  To: passt-dev

Debian cross-building automatic checks:

  http://crossqa.debian.net/src/passt

currently fail because we don't use the right target architecture and
compiler while building the system call lists and resolving their
numbers in seccomp.sh. Pass ARCH and CC to seccomp.sh and use them.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 Makefile   | 2 +-
 seccomp.sh | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 667ddfb..e5723a7 100644
--- a/Makefile
+++ b/Makefile
@@ -105,7 +105,7 @@ static: FLAGS += -static -DGLIBC_NO_STATIC_NSS
 static: clean all
 
 seccomp.h: seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
-	@ EXTRA_SYSCALLS="$(EXTRA_SYSCALLS)" ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
+	@ EXTRA_SYSCALLS="$(EXTRA_SYSCALLS)" ARCH="$(TARGET_ARCH)" CC="$(CC)" ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
 
 passt: $(PASST_SRCS) $(HEADERS)
 	$(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS)
diff --git a/seccomp.sh b/seccomp.sh
index 31ea8da..b075efd 100755
--- a/seccomp.sh
+++ b/seccomp.sh
@@ -17,6 +17,9 @@ TMP="$(mktemp)"
 IN="$@"
 OUT="seccomp.h"
 
+[ -z "${ARCH}" ] && ARCH="$(uname -m)"
+[ -z "${CC}" ] && CC="cc"
+
 HEADER="/* This file was automatically generated by $(basename ${0}) */
 
 #ifndef AUDIT_ARCH_PPC64LE
@@ -110,7 +113,7 @@ log2() {
 # $1:	Name of syscall
 syscall_nr() {
 	__in="$(printf "#include <asm-generic/unistd.h>\n#include <sys/syscall.h>\n__NR_%s" ${1})"
-	__out="$(echo "${__in}" | cc -E -xc - -o - | tail -1)"
+	__out="$(echo "${__in}" | ${CC} -E -xc - -o - | tail -1)"
 	[ "${__out}" = "__NR_$1" ] && return 1
 
 	# Output might be in the form "(x + y)" (seen on armv6l, armv7l)
@@ -125,7 +128,7 @@ filter() {
 		case ${__c} in
 		*:*)
 			case ${__c} in
-			$(uname -m):*)
+			${ARCH}:*)
 				__arch_match=1
 				__c=${__c##*:}
 				;;
-- 
@@ -17,6 +17,9 @@ TMP="$(mktemp)"
 IN="$@"
 OUT="seccomp.h"
 
+[ -z "${ARCH}" ] && ARCH="$(uname -m)"
+[ -z "${CC}" ] && CC="cc"
+
 HEADER="/* This file was automatically generated by $(basename ${0}) */
 
 #ifndef AUDIT_ARCH_PPC64LE
@@ -110,7 +113,7 @@ log2() {
 # $1:	Name of syscall
 syscall_nr() {
 	__in="$(printf "#include <asm-generic/unistd.h>\n#include <sys/syscall.h>\n__NR_%s" ${1})"
-	__out="$(echo "${__in}" | cc -E -xc - -o - | tail -1)"
+	__out="$(echo "${__in}" | ${CC} -E -xc - -o - | tail -1)"
 	[ "${__out}" = "__NR_$1" ] && return 1
 
 	# Output might be in the form "(x + y)" (seen on armv6l, armv7l)
@@ -125,7 +128,7 @@ filter() {
 		case ${__c} in
 		*:*)
 			case ${__c} in
-			$(uname -m):*)
+			${ARCH}:*)
 				__arch_match=1
 				__c=${__c##*:}
 				;;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Makefile, seccomp.sh: Fix cross-builds, adjust syscalls list to compiler
  2023-02-28 10:17 [PATCH] Makefile, seccomp.sh: Fix cross-builds, adjust syscalls list to compiler Stefano Brivio
@ 2023-03-01  3:24 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2023-03-01  3:24 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 2356 bytes --]

On Tue, Feb 28, 2023 at 11:17:27AM +0100, Stefano Brivio wrote:
> Debian cross-building automatic checks:
> 
>   http://crossqa.debian.net/src/passt
> 
> currently fail because we don't use the right target architecture and
> compiler while building the system call lists and resolving their
> numbers in seccomp.sh. Pass ARCH and CC to seccomp.sh and use them.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  Makefile   | 2 +-
>  seccomp.sh | 7 +++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 667ddfb..e5723a7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -105,7 +105,7 @@ static: FLAGS += -static -DGLIBC_NO_STATIC_NSS
>  static: clean all
>  
>  seccomp.h: seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
> -	@ EXTRA_SYSCALLS="$(EXTRA_SYSCALLS)" ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
> +	@ EXTRA_SYSCALLS="$(EXTRA_SYSCALLS)" ARCH="$(TARGET_ARCH)" CC="$(CC)" ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
>  
>  passt: $(PASST_SRCS) $(HEADERS)
>  	$(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS)
> diff --git a/seccomp.sh b/seccomp.sh
> index 31ea8da..b075efd 100755
> --- a/seccomp.sh
> +++ b/seccomp.sh
> @@ -17,6 +17,9 @@ TMP="$(mktemp)"
>  IN="$@"
>  OUT="seccomp.h"
>  
> +[ -z "${ARCH}" ] && ARCH="$(uname -m)"
> +[ -z "${CC}" ] && CC="cc"
> +
>  HEADER="/* This file was automatically generated by $(basename ${0}) */
>  
>  #ifndef AUDIT_ARCH_PPC64LE
> @@ -110,7 +113,7 @@ log2() {
>  # $1:	Name of syscall
>  syscall_nr() {
>  	__in="$(printf "#include <asm-generic/unistd.h>\n#include <sys/syscall.h>\n__NR_%s" ${1})"
> -	__out="$(echo "${__in}" | cc -E -xc - -o - | tail -1)"
> +	__out="$(echo "${__in}" | ${CC} -E -xc - -o - | tail -1)"
>  	[ "${__out}" = "__NR_$1" ] && return 1
>  
>  	# Output might be in the form "(x + y)" (seen on armv6l, armv7l)
> @@ -125,7 +128,7 @@ filter() {
>  		case ${__c} in
>  		*:*)
>  			case ${__c} in
> -			$(uname -m):*)
> +			${ARCH}:*)
>  				__arch_match=1
>  				__c=${__c##*:}
>  				;;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-01  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 10:17 [PATCH] Makefile, seccomp.sh: Fix cross-builds, adjust syscalls list to compiler Stefano Brivio
2023-03-01  3:24 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).