From patchwork Sun Jul 28 10:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814927 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC93D22EE5; Sun, 28 Jul 2024 10:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161418; cv=none; b=Xlcj36oPYmNmKk1fw07ugJbUVrXXcctq1Px3KmOJ91nHq/VCsw6O9oz0C1+mglddvH6080rnq90H4svuJHRaA7gMitCCCwsjMMy+V3dFZ11cTOrBIvX7he/9DlkPh3fzQjB3UPKADBJ1YFG89oCuSIUVyUm1eYhzzZ472SEB4ss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161418; c=relaxed/simple; bh=zn9iXWwceqvz8uRN8Yt/9Xv1URTnsny/0GYBzVr0zFM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MWqUlSDsSErtRyVZ191dDGZ6eTUbxk/e94LLAulfTfuFZy/9hGprLal6/DU36yREjgvFJNf2uyYyNO0C2xuFtN/3MUvB64Vh7OvLDfFlg5PLRV1taGsS+WWcLItme8JOa/5jbEgON+zlA98cMFZpLNTQJU6q190W8DPlCLIE2EM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=GtBMYezq; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="GtBMYezq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=zn9iXWwceqvz8uRN8Yt/9Xv1URTnsny/0GYBzVr0zFM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GtBMYezq2amqYqZBbBqOjYRUKX0Ewf1NpjYDwaeF2UxTMkQcrbfNqXlvtnWA5jsvU ZI5HYrMYboqor9lGKNuautEx+9yVMc8ttxyjf7PU9yUx1aYYpxElzo3/zdTuGHT1BW OAFRZb7qLJWIkpmVZPDrnn+iCIChVLSh0aX6pb8g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:09:55 +0200 Subject: [PATCH 01/12] tools/nolibc: use clang-compatible asm syntax in arch-arm.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-1-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1062; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zn9iXWwceqvz8uRN8Yt/9Xv1URTnsny/0GYBzVr0zFM=; b=enN4XiLb0dsZ/7AxXdEWeQT7gNJKUT0res8jlSd+0S6wH7FcOOQA6jB85VU0RAfhucfHU4X1Y qYzUfvUMKy5Cjd2oWe9H6q8OezDnu4OChbD9z8+Lmqmy8jx8BwjLFu4 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The clang assembler rejects the current syntax. Switch to a syntax accepted by both GCC and clang. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-arm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index cae4afa7c1c7..d1c19d973e55 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -188,8 +188,8 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( - "mov %r0, sp\n" /* save stack pointer to %r0, as arg1 of _start_c */ - "and ip, %r0, #-8\n" /* sp must be 8-byte aligned in the callee */ + "mov r0, sp\n" /* save stack pointer to %r0, as arg1 of _start_c */ + "and ip, r0, #-8\n" /* sp must be 8-byte aligned in the callee */ "mov sp, ip\n" "bl _start_c\n" /* transfer to c runtime */ ); From patchwork Sun Jul 28 10:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814929 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AB971B86E7; Sun, 28 Jul 2024 10:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; cv=none; b=Ul+dmc1hf31yYC+Qq+RJNMbN9n+vqEhE5NRSFQLWdvetIebOpYYR/DhYsNaku1ITTc+fNZi4zWYrj1bCzYRvz1VVeDiWQmqurQczNmtFbQCpJa716IWVuAfPdKlmkWEsQZgFQne9SMSCJDa5tFC9swO1uSFy5QftSSJYAfbhlPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; c=relaxed/simple; bh=dhMCN7pEEyNix1uoUAGJom0GonyZA1rMiLcJNDosUbw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mlRAui/lWh8nQhe59frbj5t7I9zXXl4jjGSPZ/YCfB98dI2wz6fpsefKpLtrPiu/kJ3up2vxomBsfN2kBT3KKYe0zkbEthjIwUu1UEC6jejBlfNRn+mpcF6UTbWao7HFQTN73OPpmkbyF0Vz0YN/WLaCxD2UPbwZT9CHkmBYruk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=N66gcAkH; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="N66gcAkH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=dhMCN7pEEyNix1uoUAGJom0GonyZA1rMiLcJNDosUbw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=N66gcAkHylLosbR/hLBt9ltg5c+YssMjmafowZ1xZkurRA9GZi8spIMJT1XtAGnXY yhRULhAZX8c2jxAjv0SEKkcvlfxbOK0/cgmK8yKFccRawTciNUGvk3KfFwqtI19awX dIRRrYs8X9TVkB1QSMxv9gRuJcFTFWezF3RhrBqY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:09:56 +0200 Subject: [PATCH 02/12] tools/nolibc: limit powerpc stack-protector workaround to GCC Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-2-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1020; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dhMCN7pEEyNix1uoUAGJom0GonyZA1rMiLcJNDosUbw=; b=StFfgnxzsMDpkgz1dF9GKQjwrNadJGR/+HYcD6p5Zf5yZ1cSYYJf+zNkZpsKgn+Zoo8BF3mAH QiL4Io8zjydBPJ68Fh93HGhFe1sfw5zqE2EH39wr9VJf9hAh77ORymW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= As mentioned in the comment, the workaround for __attribute__((no_stack_protector)) is only necessary on GCC. Avoid applying the workaround on clang, as clang does not recognize __attribute__((__optimize__)) and would fail. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-powerpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h index ac212e6185b2..41ebd394b90c 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -172,7 +172,7 @@ _ret; \ }) -#ifndef __powerpc64__ +#if !defined(__powerpc64__) && !defined(__clang__) /* FIXME: For 32-bit PowerPC, with newer gcc compilers (e.g. gcc 13.1.0), * "omit-frame-pointer" fails with __attribute__((no_stack_protector)) but * works with __attribute__((__optimize__("-fno-stack-protector"))) From patchwork Sun Jul 28 10:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814928 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC97923776; Sun, 28 Jul 2024 10:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; cv=none; b=eBtqg83ipEFeDDm1H3awqB7TBCuv80pZcVts8MgiHLVzBn53yEaiAJm15Q0RwxZ0bHbjC9GQmM3w5hS/5YgDvpes6tVV0QdA80+I+cNtjek1Orp6+qKYRPQ+3HE/NLo9lF/Bw6VOzQ0MoyabNm7DO4Hov3Ee2jYVmRBmS7lFg80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; c=relaxed/simple; bh=pI+x6cfc3CM2BKGrZPpdw/rz5+r1qGR4nRV3usuJ5tk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UYZlwIq7pRZcuWkoXlJIIB2UPpeWP2aNSn3g+/XbjkVuE7xphrLTw+NpcE0LFCAreRh7k3/LM0vGtcpVmh0QS0hfqiSe9ZbRLkAOaMLndaV6FF9cT53NLhpmnZqTfAqAd4j4tfGSIXLLP0vJhQIT36NuCbznFn2V6S2GraYjnEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=oDXNA0V+; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="oDXNA0V+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=pI+x6cfc3CM2BKGrZPpdw/rz5+r1qGR4nRV3usuJ5tk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oDXNA0V+e8Yn32TLCDfURXpxrXPGuX16VnrD6njGsAN3R+TZtVk6qPDVyDuaRRaP3 9OPfq0yNygK1Hi5w4FDO8HLFWWlINYvD9AlMKKCEhsqOVaO0YrHEaa29y32TRxg3pV cWpyEQn7hGTX4NxMLAL75zUrWrW0DUD2HGS5sRbo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:09:57 +0200 Subject: [PATCH 03/12] tools/nolibc: move entrypoint specifics to compiler.h Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-3-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=9528; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=pI+x6cfc3CM2BKGrZPpdw/rz5+r1qGR4nRV3usuJ5tk=; b=Xd7Cj5HjBHpB/0rozx/xwNba9KmOcId88wGhbp8IR/L58SQhaqkxJ3Uqh7vtfPR7/nh9CiMfS qvtN6qJAqpsAhZyzNna5RdMvqOAIeg7zT3xAan61JehPt7bK00iIVbZ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The specific attributes for the _start entrypoint are duplicated for each architecture. Deduplicate it into a dedicated #define into compiler.h. This make the code shorter and will make it easier to adapt for clang compatibility. For clang compatibility, the epilogue will also need to be adapted, so move that one, too. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-aarch64.h | 4 ++-- tools/include/nolibc/arch-arm.h | 4 ++-- tools/include/nolibc/arch-i386.h | 4 ++-- tools/include/nolibc/arch-loongarch.h | 4 ++-- tools/include/nolibc/arch-mips.h | 4 ++-- tools/include/nolibc/arch-powerpc.h | 4 ++-- tools/include/nolibc/arch-riscv.h | 4 ++-- tools/include/nolibc/arch-s390.h | 4 ++-- tools/include/nolibc/arch-x86_64.h | 4 ++-- tools/include/nolibc/compiler.h | 3 +++ 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index b23ac1f04035..d5b182115664 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -142,13 +142,13 @@ }) /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "mov x0, sp\n" /* save stack pointer to x0, as arg1 of _start_c */ "and sp, x0, -16\n" /* sp must be 16-byte aligned in the callee */ "bl _start_c\n" /* transfer to c runtime */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_AARCH64_H */ diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index d1c19d973e55..8e8a681a0740 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -185,7 +185,7 @@ }) /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "mov r0, sp\n" /* save stack pointer to %r0, as arg1 of _start_c */ @@ -193,7 +193,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "mov sp, ip\n" "bl _start_c\n" /* transfer to c runtime */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_ARM_H */ diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index 28c26a00a762..a464e3ae17fd 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -162,7 +162,7 @@ * 2) The deepest stack frame should be set to zero * */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "xor %ebp, %ebp\n" /* zero the stack frame */ @@ -174,7 +174,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "call _start_c\n" /* transfer to c runtime */ "hlt\n" /* ensure it does not return */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_I386_H */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index 3f8ef8f86c0f..b3edb10be4c7 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -149,14 +149,14 @@ #endif /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "move $a0, $sp\n" /* save stack pointer to $a0, as arg1 of _start_c */ LONG_BSTRINS " $sp, $zero, 3, 0\n" /* $sp must be 16-byte aligned */ "bl _start_c\n" /* transfer to c runtime */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_LOONGARCH_H */ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 62cc50ef3288..afa5adc8c76b 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -179,7 +179,7 @@ }) /* startup code, note that it's called __start on MIPS */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector __start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector __start(void) { __asm__ volatile ( ".set push\n" @@ -198,7 +198,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ " nop\n" /* delayed slot */ ".set pop\n" ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_MIPS_H */ diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h index 41ebd394b90c..c0a2d08e4e51 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -184,7 +184,7 @@ #endif /* !__powerpc64__ */ /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { #ifdef __powerpc64__ #if _CALL_ELF == 2 @@ -215,7 +215,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "bl _start_c\n" /* transfer to c runtime */ ); #endif - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_POWERPC_H */ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 1927c643c739..90da3b328f6f 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -140,7 +140,7 @@ }) /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( ".option push\n" @@ -151,7 +151,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "andi sp, a0, -16\n" /* sp must be 16-byte aligned */ "call _start_c\n" /* transfer to c runtime */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #endif /* _NOLIBC_ARCH_RISCV_H */ diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 5d60fd43f883..09123861a140 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -139,7 +139,7 @@ }) /* startup code */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "lgr %r2, %r15\n" /* save stack pointer to %r2, as arg1 of _start_c */ @@ -147,7 +147,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "xc 0(8,%r15), 0(%r15)\n" /* clear backchain */ "brasl %r14, _start_c\n" /* transfer to c runtime */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } struct s390_mmap_arg_struct { diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index 68609f421934..98cb693cc38c 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -161,7 +161,7 @@ * 2) The deepest stack frame should be zero (the %rbp). * */ -void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +void __attribute__((weak, noreturn)) __entrypoint __no_stack_protector _start(void) { __asm__ volatile ( "xor %ebp, %ebp\n" /* zero the stack frame */ @@ -170,7 +170,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "call _start_c\n" /* transfer to c runtime */ "hlt\n" /* ensure it does not return */ ); - __builtin_unreachable(); + __entrypoint_epilogue(); } #define NOLIBC_ARCH_HAS_MEMMOVE diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index beddc3665d69..fe3701863634 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -6,6 +6,9 @@ #ifndef _NOLIBC_COMPILER_H #define _NOLIBC_COMPILER_H +#define __entrypoint __attribute__((optimize("Os", "omit-frame-pointer"))) +#define __entrypoint_epilogue() __builtin_unreachable() + #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) #define _NOLIBC_STACKPROTECTOR From patchwork Sun Jul 28 10:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 815521 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ABD218EAD; Sun, 28 Jul 2024 10:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; cv=none; b=AbJhdi46b7O8szTP2Ktino0m7lFuUzKtLw1XDcOBcSifFIqhDRq2SnT/GsN/BQG1T/K8VKdsuhYo9OrwtiLmgqgAomYVYjQ4J2iIwbahz4G2Ogv37iKtn5ct8ku1UTgICTnlfL+WRybEEj/ISHnpuOpZovDOAUnSVAs5ldENsM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161417; c=relaxed/simple; bh=GxSzGOHKEeRjWP3xVjt6xdWG7hTZQxCczvHBYzc4qlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e15F344Cj3ytVNFWyrbbIiDjH4cvRLtd2tPab0ZUaEeePCkZP6SZkTHmgdXxgqUhW4heNpkYafJyfjrDFna5FF1HpEsKUau4V71d5etxSHsIS65xbpiycjpLmrOKpt/x/bYdcpKvyb+BlDi603j5G/zPRlSmaSX/RYlaMcdG7GI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=doAWTjNN; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="doAWTjNN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=GxSzGOHKEeRjWP3xVjt6xdWG7hTZQxCczvHBYzc4qlQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=doAWTjNNmXDHTRrVpHvfdLySLyundnPs+8qf6pP7RMI/VtoJbsMModZNxEJViF8Lr Jnoff18zcsh+sFozWMX1P4KfB95ZV5WD3QT8I/54j+LPrwoL/JD3+WLIlSkLBv5+zN 3Buek6Xgrvv1GM1MlZwq3dywVN3unuEFur6fb9go= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:09:58 +0200 Subject: [PATCH 04/12] tools/nolibc: use attribute((naked)) if available Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-4-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1386; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=GxSzGOHKEeRjWP3xVjt6xdWG7hTZQxCczvHBYzc4qlQ=; b=2zz/Gyo+bbly/Yk7JgL6hkfk9330xWmuID8rgFn7Zqmr7Qqg4q2o/ni8KIiSXdry/nKr4NAmz nLttwgOE1MlAbnXg6oS7gK1MDVUN+qC9WeF7og4+T2CPxo8MHIWAn6p X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The current entrypoint attributes optimize("Os", "omit-frame-pointer") are intended to avoid all compiler generated code, like function porologue and epilogue. This is the exact usecase implemented by the attribute "naked". Unfortunately this is not implemented by GCC for all targets, so only use it where available. This also provides compatibility with clang, which recognizes the "naked" attribute but not the previously used attribute "optimized". Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index fe3701863634..f77bb7d3e1a8 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -9,6 +9,15 @@ #define __entrypoint __attribute__((optimize("Os", "omit-frame-pointer"))) #define __entrypoint_epilogue() __builtin_unreachable() +#if defined(__has_attribute) +# if __has_attribute(naked) +# undef __entrypoint +# define __entrypoint __attribute__((naked)) +# undef __entrypoint_epilogue +# define __entrypoint_epilogue() +# endif +#endif /* defined(__has_attribute) */ + #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) #define _NOLIBC_STACKPROTECTOR From patchwork Sun Jul 28 10:09:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 815518 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A27443BBD8; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; cv=none; b=qXrFM7Egau0jmPibISc7wl93BwVmmfMmuHdL0S95gk39Z/Muc8iPwPlhNNQ9w8LwCJ8+zvlM0J7H7Sj/n7zWOVj+Ql3pdm0qo/bB7kXyRUyOtrR8QQSvbWAIZnlZu4nCrl0iUgX979DcsxX1eh3UEgFfxk8txJ9HrWHZebWkPyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; c=relaxed/simple; bh=HhxOZYqnzVx7tmwtHxKV0fQk9a2vX+belMUnjSiyOSw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VPYS4gGdGCt07XgfI4l4Dt38U1nfDP7UwCBW74TEZsTWeQNvRwbWgvoo9wiCD9wVC85hw7+/ibXwG+IombWa0CO4f+43RAE6F4ALi27/UFIUe3dZxqSCXPLfIEL47C51CGRDYFLLf9LwyrXxtXrW6UmUyQ8IW6rSy1edlfnH/gE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=P+zDsOUO; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="P+zDsOUO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=HhxOZYqnzVx7tmwtHxKV0fQk9a2vX+belMUnjSiyOSw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P+zDsOUON7eKhnx0q3g+1vO9PxZHMTvZ7zJjQBpnU5QBV/2LifEOVa8mEBszjEOSS X14rMGEP7FCta5thqtoKLd0iX1KTccP27UiwmYnDeJ8a9j3hNByaZbeMYzeBG0IYTn IZ0V8pCnRHvI9NIAthlvPRpKZXdEp0hypm6dykKo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:09:59 +0200 Subject: [PATCH 05/12] selftests/nolibc: report failure if no testcase passed Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-5-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1001; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=HhxOZYqnzVx7tmwtHxKV0fQk9a2vX+belMUnjSiyOSw=; b=K+mg+H91EkPWJuuw17d9UaczssIUxIFRcewKx9aTxpl+d1ev6E+Jn0ve1nqXUcTwI180K6HiI z6UYwJ6J+J1B6JSyGtiAU9sY8etY+ie2D9aPgX2Ng8BUv3Roj1k0Jh4 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= When nolibc-test is so broken, it doesn't even start, don't report success. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 3fbabab46958..46dfbb50fae5 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -157,7 +157,7 @@ LDFLAGS := REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++; print;} /\[SKIPPED\][\r]*$$/{s++} \ END{ printf("\n%3d test(s): %3d passed, %3d skipped, %3d failed => status: ", p+s+f, p, s, f); \ - if (f) printf("failure\n"); else if (s) printf("warning\n"); else printf("success\n");; \ + if (f || !p) printf("failure\n"); else if (s) printf("warning\n"); else printf("success\n");; \ printf("\nSee all results in %s\n", ARGV[1]); }' help: From patchwork Sun Jul 28 10:10:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814926 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9DC1381B0; Sun, 28 Jul 2024 10:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161420; cv=none; b=TnuRb4hL+Trwo4xnWxDJhop/6ozhCj/JB4bFKuSXrVlWtS8vY8FU0aeyZTkTlg4eLGDExq9RplDgR/fLv+oMxsFGmQ39pXL0SzM/LpptK9r7wFOOZzKOZiMv2KdFK2URI9ggf7bUYMe82SMFPrG6H9m2Jb9EXr3jwpso6L/3wF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161420; c=relaxed/simple; bh=lo6aJXOfjDRlyr2OAinpgQZv73POOs4srT6onhZTZKw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sFMpW9x/bZcEeC+tK3McaJDRrF4gVtqZrJCDfjCyF14J1gAG7NisyrjS1UBTVFBoEdK1kqsuL+iaYYLuvpsskYQxyzdWFziHJiWYhk0xMKMOYhBln22P7+CDukrxNwfbiYgwBmvkldaWQ+pa8O0FA7Psw3HpcrFG1+t6yx9LFIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=e/xkfjJ4; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="e/xkfjJ4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=lo6aJXOfjDRlyr2OAinpgQZv73POOs4srT6onhZTZKw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=e/xkfjJ4dJ0C5DlpCqrXWxE1GnoxaLPGlc9UdXAjlrbvWL/5I/vUmRyhdZrI//22c cuRvssGzNW7XBY61+kzKL8yoJo3IidG0XrlQobsvTARmy7YvhYn//l6KF/9bcfl2+x orfrnuit3Sv/16d5iD0yYPk4GKyopO9AbdN3BpPE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:00 +0200 Subject: [PATCH 06/12] selftests/nolibc: avoid passing NULL to printf("%s") Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-6-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1027; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=lo6aJXOfjDRlyr2OAinpgQZv73POOs4srT6onhZTZKw=; b=Dv4cgcH/AUMGAp4+z1OvGbmQf7Hxb7fm3mt3D/t8n3oidT0Z6dHwa/eyG8T7uid7U91jsBBHc Qa38QwRevryDjxUDkG6cBysPAwDFkvc5xwcN2K8QcwAO9E0yJCJJ7Ww X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Clang on higher optimization levels detects that NULL is passed to printf("%s") and warns about it. Avoid the warning. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 093d0512f4c5..8cbb51dca0cd 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -542,7 +542,7 @@ int expect_strzr(const char *expr, int llen) { int ret = 0; - llen += printf(" = <%s> ", expr); + llen += printf(" = <%s> ", expr ? expr : "(null)"); if (expr) { ret = 1; result(llen, FAIL); @@ -561,7 +561,7 @@ int expect_strnz(const char *expr, int llen) { int ret = 0; - llen += printf(" = <%s> ", expr); + llen += printf(" = <%s> ", expr ? expr : "(null)"); if (!expr) { ret = 1; result(llen, FAIL); From patchwork Sun Jul 28 10:10:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814923 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85E613A8E4; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161422; cv=none; b=YsUIJrny6QucKi9+dq6ntapdtlk1VhgYeV6nAjdo9L1X6qLxFwvikhG8joT92iAe5VIcPskhvuN6xi5ssItKzlVyDQOf6SXQ5mHmZyhfyKYe2qtnRmXRejBljYrljtg/FywOjhUYZUI75cR7sokq2VXJnI1QY8eQajkbL3TpbbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161422; c=relaxed/simple; bh=LYVnkfOk8azVIIqLsIbtUPX96L6ih96CBmHiy7nNCmk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YJsoKpJPpbV1aiU2V94EKRof1Z42wT7lLnsc9XrgTdH/JvR8uXM5BR5oJpwBOKpxl+r5J8quMKqSoo1ii3KiEO0o17dKaT67ewKM8Etg15qUPF/oBB3gkzmH2VZSFwF/26k3BHJwKB2N726Bl5ATgCtR6xW2cB8+2JmSfAy0Kos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=eSYczxSC; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="eSYczxSC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=LYVnkfOk8azVIIqLsIbtUPX96L6ih96CBmHiy7nNCmk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eSYczxSCPTWxLilzT+dTYHsV+ajVKubS7sI497PJRbTsxaAvoSCJM5X/bdg9oHde8 wOzWaEJWu9r22CCDRXEZ6+qgtzP/2Z3Ix8OPOHtOCmkhrZ8sgXocwsEXG0V6VROIEr 6xgZ55A4b+3Fp8LRdd30FBcREu9LlAqc2ysehg3g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:01 +0200 Subject: [PATCH 07/12] selftests/nolibc: determine $(srctree) first Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-7-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1396; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=LYVnkfOk8azVIIqLsIbtUPX96L6ih96CBmHiy7nNCmk=; b=XZLm41/WkvS5dnszYTu3j0CUw80qSXYzJZpRjecEctA8YbXWvHery96LrmE6BMVjnyLwC+WSK E3TPY2NM/4YDZAsMG9lJ4Y46pI2gqjul2FsFrk3cCzl/1u8nqFYZyWu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Avoid needing relative includes. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 46dfbb50fae5..803a4e1bbe24 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -1,9 +1,14 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for nolibc tests -include ../../../scripts/Makefile.include -include ../../../scripts/utilities.mak +# we're in ".../tools/testing/selftests/nolibc" +ifeq ($(srctree),) +srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) +endif + +include $(srctree)/tools/scripts/Makefile.include +include $(srctree)/tools/scripts/utilities.mak # We need this for the "cc-option" macro. -include ../../../build/Build.include +include $(srctree)/tools/build/Build.include ifneq ($(O),) ifneq ($(call is-absolute,$(O)),y) @@ -11,11 +16,6 @@ $(error Only absolute O= parameters are supported) endif endif -# we're in ".../tools/testing/selftests/nolibc" -ifeq ($(srctree),) -srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) -endif - ifeq ($(ARCH),) include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) From patchwork Sun Jul 28 10:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 815519 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A37A23716D; Sun, 28 Jul 2024 10:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161420; cv=none; b=EuB0XddgjTl+xP2gvOHxqlDBF+ptBNLe9hPnxuNroW44YKwHcNt+teqH0U4P+s238wNVWY23Idjfp/tdTd6UXjuWcMQMoUfAxPSyZvxwN5JisuSqDg8JruMnVM24dff3vkY9q4C8m3ewhBSwkuAR4sFMXNytr5hI8V+HVVNw6GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161420; c=relaxed/simple; bh=h/BgI+G7ScwU6DQ48y7tlStVhparWhO6ZDGIMqrbJic=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=vEVGj6o31X3MyWxXLnl7jgobF0nAKiGLIMNS0j6n+asa6yXoqDgnEUk36JKZwnsj2WAlbceCkCJ8DOlXBcO1nhUdKat+df9c3tcSYV6raMPKeMVgvzGLGVsHAIeS470rJJm8P2uiFO4w92GrSUlXISuKN8uA+sUhvZ607Mq8tTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=WfvFwjDC; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="WfvFwjDC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=h/BgI+G7ScwU6DQ48y7tlStVhparWhO6ZDGIMqrbJic=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WfvFwjDCuOFT6qPBwBI5QDXv9OU5+xvjnTUdlY1PZ1D0IzNptdnSEwHd4lZjddMwK teliQDJpVdXXcYxoCGL/C9+IMr+bfmcB78amTjGsiiMO2b3lrq/l/UvF2gdQcUJEYd gzlOM9HFL7OQNTSv5CqTAz/I2NjRK3nCCTWZ7LnM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:02 +0200 Subject: [PATCH 08/12] selftests/nolibc: setup objtree without Makefile.include Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-8-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1710; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=h/BgI+G7ScwU6DQ48y7tlStVhparWhO6ZDGIMqrbJic=; b=QlImsRN3Q2Vy+tVFvto+/SCpb8gpujf9wlvl0kTfCkhm38xgV8n+7uhBkwSonY8KiJOE0si5M z4BYQLdgjGOB4oWIfOCQftp6qY/o4SNy/iDV142DxxHeG0zoPrUkYOs X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Makefile.include has multiple uses. In addition to the setup of various variables based on "O=", for which it is used currently, it can also set up variables based on "LLVM=". Unfortunately using it for both at the same time would require a big ugly reshuffling of the nolibc Makefile. As we want to use its llvm handling in the future, reimplement its objtree := $(O). While at it, also move "$(objtree) ?= $(srctree)" for consistency. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 803a4e1bbe24..8000bc3c408b 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -5,7 +5,6 @@ ifeq ($(srctree),) srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) endif -include $(srctree)/tools/scripts/Makefile.include include $(srctree)/tools/scripts/utilities.mak # We need this for the "cc-option" macro. include $(srctree)/tools/build/Build.include @@ -14,6 +13,9 @@ ifneq ($(O),) ifneq ($(call is-absolute,$(O)),y) $(error Only absolute O= parameters are supported) endif +objtree := $(O) +else +objtree ?= $(srctree) endif ifeq ($(ARCH),) @@ -21,8 +23,6 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif -objtree ?= $(srctree) - # XARCH extends the kernel's ARCH with a few variants of the same # architecture that only differ by the configuration, the toolchain # and the Qemu program used. It is copied as-is into ARCH except for From patchwork Sun Jul 28 10:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 815516 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 213993F9EC; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; cv=none; b=teShoJfuUyj0n8oWZbNZw6e4syyF2zeunhcii36v4PDmpm4Ws/k57GtYFxISqxqY1nZQRZxgsgv/xVES9nF1ftRm8wBEkC+JqV57/mmp2GKtyOrgcdRjB1FbeZg6vEMPHwKJJJVJT5d8HC6NXOYDa6b+7Q1+BO8lq1ieGgnvidw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; c=relaxed/simple; bh=WpLErwbIOnDQlI1CEKK7Shd+jxySTINo7VNwEfZYUTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EU6IvCTZIbUOTopcptcZdRrSTF/XxuBnu+ohGg9cLAazlufTUpkOLjLK1OkJ3lpVSga+/K+w97JCd3i/K8pmFlw9VXirnezDU60EfmY13uydGmxGa/9KZpdJsSATyNi/shFT8jz5QGd/++uAdM1lQgIUyRcYMPbrWvVQx6CB4uc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=OvVm/KUd; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="OvVm/KUd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=WpLErwbIOnDQlI1CEKK7Shd+jxySTINo7VNwEfZYUTg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OvVm/KUdBQ0x9DOSKZVHBXxKhOc+HXE118h7CeI6hidvPR8y1oQOI/g3xPGN1ysG8 xlLk621Ay00dHE8oAeXrE7YXOq//GA4xCpE3AN4D/Fis+//RnZHqMzObh6d/Oct27Y f4EugGqobQRZ9tqgjEp60XjH+Iw7a13q05oGG79I= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:03 +0200 Subject: [PATCH 09/12] selftests/nolibc: add support for LLVM= parameter Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-9-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1069; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=WpLErwbIOnDQlI1CEKK7Shd+jxySTINo7VNwEfZYUTg=; b=oQvqhk1sOdBQW1kiH9NRhGOIAHT6fFXMl2hUhZbjSEH4LYFZz9V3Osk6YijFwP9XbKCsJRpmg ZQukNU2xlK9BNYw3uAJEFRzj04M/SKCkezapyrvvI9sE9oijHanKQ3/ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Makefile.include can modify CC and CFLAGS for usage with clang. Make use of it. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 8000bc3c408b..cdff317c35f2 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -155,6 +155,9 @@ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex $(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA) LDFLAGS := +# Modify CFLAGS based on LLVM= +include $(srctree)/tools/scripts/Makefile.include + REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++; print;} /\[SKIPPED\][\r]*$$/{s++} \ END{ printf("\n%3d test(s): %3d passed, %3d skipped, %3d failed => status: ", p+s+f, p, s, f); \ if (f || !p) printf("failure\n"); else if (s) printf("warning\n"); else printf("success\n");; \ From patchwork Sun Jul 28 10:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 815517 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A08F93BB50; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; cv=none; b=doiY2FNyrtQZdEHnGG1MB+H9+8rwAj9/ZOfDiKqMHKmbXwI42/RaN7GLVZK4XCU0p3vVRoKJK9kyfRsurAQM6OJ9DT9LLn3k05QQIBPJR7kMtLTPpuMxD4hSNGpBLftlBYNXyxxPK6kWvjE5AP3av0vKCkimfDL7Ljofdd0RaRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; c=relaxed/simple; bh=YtQZNF1Xp01+/vf4Ug6818c6NQxMXRGBNPNru0wXX8c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H9TuWLyYF6Cng0/bYN6o4nfNZgXiBN/fvCP3UkCtKgH5dbc/FyQXMKA7f44Wlly8ZRFJtswco5KysuQzhXV0N6fvvkudmQw80PjZKZyg5OyiDww+tN2Jcx0HEzVVDMDfPtLzc98qjF7PtGu42kYK6+yVpt9YItV93qXGZufV5Xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=sK5m7f5u; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="sK5m7f5u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=YtQZNF1Xp01+/vf4Ug6818c6NQxMXRGBNPNru0wXX8c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sK5m7f5uPCn2LW08pvehygoUX/wv9JP9xbkFshZwDfLSKwJ4uz5HZVB/isyxDCXCu 7che76q4l/XSF/CAghB0AF/v72ZPj3Poql0zJK/70NvGQBlmGwiZikDtK0fE7LclIP W6RobNeshY3fqWbFNd41Sjt6080+902WaNW7BVdk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:04 +0200 Subject: [PATCH 10/12] selftests/nolibc: add cc-option compatible with clang cross builds Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-10-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1398; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YtQZNF1Xp01+/vf4Ug6818c6NQxMXRGBNPNru0wXX8c=; b=YItm5J56C4ZVJD/V0thuoQoZUzu9rt4DPk9wedEjblzaQPfaXedQEgyIv1L7uLLLJaXrMh/wg eFoGPXCkBJoButgG5N1OFIyoXhXLAEFPorDFrc+k2uwo8GOwfjA2syJ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The cc-option macro from Build.include is not compatible with clang cross builds, as it does not respect the "--target" and similar flags, set up by Mekfile.include. Provide a custom variant which works correctly. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index cdff317c35f2..b8577086e008 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -6,8 +6,8 @@ srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) endif include $(srctree)/tools/scripts/utilities.mak -# We need this for the "cc-option" macro. -include $(srctree)/tools/build/Build.include +# We need this for the "__cc-option" macro. +include $(srctree)/scripts/Makefile.compiler ifneq ($(O),) ifneq ($(call is-absolute,$(O)),y) @@ -23,6 +23,8 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +cc-option = $(call __cc-option, $(CC),$(CLANG_CROSS_FLAGS),$(1),$(2)) + # XARCH extends the kernel's ARCH with a few variants of the same # architecture that only differ by the configuration, the toolchain # and the Qemu program used. It is copied as-is into ARCH except for From patchwork Sun Jul 28 10:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814925 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E8823BB24; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; cv=none; b=c4cB69+c6mBx3t/LvB2tcrIlfp40WkjheNkVZaJ7p4MEa6o0FUSmrF2ofVMMJ/7DpL28dzVe8vRUzjJfIwTGNI/zWZhwp4d9dy4wLBWvPn/sr8FRmjcNLRH1csmhIZWjn5Q3MSw3kbZDrvbBqDEelNcIIfrmkj9hJtTHi/7qmjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; c=relaxed/simple; bh=y2afXACcLDaFX3zkiEL9TM0mUXBaMn2Zx8HipnSDda8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=laWP6s6UHMvmQWYqArHyuq/dXcQ/5H9gTjViEw5vfG34DiwxHtDa+99SDFV7viH1Ond2RSmV46FcQTCVDeloFP/o3nlGsmGTUJ/ezSFYJNcl71FZaWQF23BrNq7Z+9P4C8IqWhuYENVVYY8rN2wO3SzWCEhNroAPrelXh8pLxzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=C1DgjJTG; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="C1DgjJTG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=y2afXACcLDaFX3zkiEL9TM0mUXBaMn2Zx8HipnSDda8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C1DgjJTG089t9CZsv/NnSgz2hHXCWy/fN6oryUWj391sTs63eg1x/apskTiWenqQ1 5q61Q6drEmkHHdXfwD7k25MwCO3eRYILjwEHjUIJHg8siU+sjiiyjDo2b7KHI9SErQ Z2ZVboj8P2hGLwoP7CZhsOT8YTdR3EUzCw2Miqu4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:05 +0200 Subject: [PATCH 11/12] selftests/nolibc: run-tests.sh: avoid overwriting CFLAGS_EXTRA Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-11-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=1485; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=y2afXACcLDaFX3zkiEL9TM0mUXBaMn2Zx8HipnSDda8=; b=W2/Qu+gER8dEDijIyITmcbJhA20YxfQaMVKgcyZEnwAnWlKpyzn4KLp1P6/MACeU/xs6yIG4n 9nhtefwygCzD6XT6J0UtqOHH+sRjaio3ptrwDLYRyAOABlt91ORuedj X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= If the user specified their own CFLAGS_EXTRA these should not be overwritten by `-e`. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/run-tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index 0446e6326a40..324509b99e2c 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -15,7 +15,7 @@ download_location="${cache_dir}/crosstools/" build_location="$(realpath "${cache_dir}"/nolibc-tests/)" perform_download=0 test_mode=system -CFLAGS_EXTRA="-Werror" +werror=1 archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv s390 loongarch" TEMP=$(getopt -o 'j:d:c:b:a:m:peh' -n "$0" -- "$@") @@ -69,7 +69,7 @@ while true; do test_mode="$2" shift 2; continue ;; '-e') - CFLAGS_EXTRA="" + werror=0 shift; continue ;; '-h') print_usage @@ -140,6 +140,9 @@ test_arch() { ct_abi=$(crosstool_abi "$1") cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") build_dir="${build_location}/${arch}" + if [ "$werror" -ne 0 ]; then + CFLAGS_EXTRA="$CFLAGS_EXTRA -Werror" + fi MAKE=(make -j"${nproc}" XARCH="${arch}" CROSS_COMPILE="${cross_compile}" O="${build_dir}") mkdir -p "$build_dir" From patchwork Sun Jul 28 10:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 814924 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA85D3CF6A; Sun, 28 Jul 2024 10:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; cv=none; b=dvIAsxrgpK46sdcC4TABI9n/p7Sya7QTpJyFX8x/kFkfQSimL676DEFc7/GpIonzIaD5xgCvlu8lLGB4tSmieWs0clGEvzZw92qE8hdiPUBVpuEOUmDSFdOu32zEBN+y6SSrMbnXeWWeHuSkGDbjBxIGEmV2kbIMrJgmGRXrWhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722161421; c=relaxed/simple; bh=bu6BXVgDQz93WjQMv8cBNw04MEOH0AkMEQwXbWZz8k8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B0mLM+wAKl1I0kFLJnnxivNqWWnPQATx/C+FmjAZk8Wew3cO5q06CHRaUkvmsXbooD0tOobkuj4+RSL8MbH6qSooBXDT/ulfwiLuxtlCKnesJxG60jdBWDkwYameLmgw4x7tvr8hFueK5UTtBIIg7rIeKwsfGzG5XwAlXraKIQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=jx5Kvbha; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="jx5Kvbha" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1722161406; bh=bu6BXVgDQz93WjQMv8cBNw04MEOH0AkMEQwXbWZz8k8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jx5KvbhaQA5imi8g09WctweudkDp1Cy1MEYgGoB1paacC4TbJ6YvOig5ciGcaRsY/ fgxeD8/7osXn679hfmp5T2+Mkz8KkHOM25evr98n2paINEcwhgxvjqNMfYnVrlnBKm UNS81QI2h/9fm8Oxf0xDUymDl6tkCW0DPMbb9COo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 28 Jul 2024 12:10:06 +0200 Subject: [PATCH 12/12] selftests/nolibc: run-tests.sh: allow building through LLVM Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240728-nolibc-llvm-v1-12-bc384269bc35@weissschuh.net> References: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> In-Reply-To: <20240728-nolibc-llvm-v1-0-bc384269bc35@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722161405; l=2021; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bu6BXVgDQz93WjQMv8cBNw04MEOH0AkMEQwXbWZz8k8=; b=BuHCk7AtLQDeKTNZGh8ki1QXJpFEKR3tyqbHhx2kopQC1ucaUglG8nuVXnozy6DwhC8U+04oY wvRGRR+kiZrDgg1Fq4tS5eo2La+K7OSCf+DK1MHKbNkrj1bzSVj3KDQ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The nolibc tests can now be properly built with LLVM. Expose this through run-tests.sh. Not all architectures are compatible, add a list for those. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/run-tests.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index 324509b99e2c..64e598ea1930 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -16,9 +16,10 @@ build_location="$(realpath "${cache_dir}"/nolibc-tests/)" perform_download=0 test_mode=system werror=1 +llvm= archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv s390 loongarch" -TEMP=$(getopt -o 'j:d:c:b:a:m:peh' -n "$0" -- "$@") +TEMP=$(getopt -o 'j:d:c:b:a:m:pelh' -n "$0" -- "$@") eval set -- "$TEMP" unset TEMP @@ -42,6 +43,7 @@ Options: -b [DIR] Build location (default: ${build_location}) -m [MODE] Test mode user/system (default: ${test_mode}) -e Disable -Werror + -l Build with LLVM/clang EOF } @@ -71,6 +73,9 @@ while true; do '-e') werror=0 shift; continue ;; + '-l') + llvm=1 + shift; continue ;; '-h') print_usage exit 0 @@ -84,6 +89,10 @@ done if [[ -n "$*" ]]; then archs="$*" +elif [[ "${llvm}" -eq 1 ]]; then + for broken in mips32le mips32be ppc64le s390; do + archs="${archs//$broken }" + done fi crosstool_arch() { @@ -143,7 +152,7 @@ test_arch() { if [ "$werror" -ne 0 ]; then CFLAGS_EXTRA="$CFLAGS_EXTRA -Werror" fi - MAKE=(make -j"${nproc}" XARCH="${arch}" CROSS_COMPILE="${cross_compile}" O="${build_dir}") + MAKE=(make -j"${nproc}" XARCH="${arch}" CROSS_COMPILE="${cross_compile}" LLVM="${llvm}" O="${build_dir}") mkdir -p "$build_dir" if [ "$test_mode" = "system" ] && [ ! -f "${build_dir}/.config" ]; then