From patchwork Wed Aug 7 21:51:37 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: 13756790 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 6D6E477F1B; Wed, 7 Aug 2024 21:51:58 +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=1723067521; cv=none; b=TPOfqGXWSr6tMaS7VFYrne9vzk1MMyuzu1xncArANCgzsaYnCzpB5UdDVUrnEw+KO6npddi9nwl7EmZM0f+qw1Ee9TBqcFo1HnLTy9m5cjOtPCQPa+zpwqNPNWoOC1RY0RojqZGLbYpT87WmOGdn8ZY1HGR6z6wUIx3h1D0q9PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067521; c=relaxed/simple; bh=V6RqjZoNDuMuFSrmOeoNBxIc8QHuAyFjHlyySjNVhEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Umcp/DEqi2Lyd28kv1HkFLjtbNRk92LvWHFhaz/8duqoRjYcY1cVbBKrhM+vWwCwGnPKo+GyyIuR4yxfe6qDcsqBfqVGAnjrHXD7h3GSzWjciWrLdDmF8GN69vayoudrOeBBYSCPHAhSlLHOubhfViXII59nIqe/yPIlpFm8k70= 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=qPmPmHWk; 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="qPmPmHWk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=V6RqjZoNDuMuFSrmOeoNBxIc8QHuAyFjHlyySjNVhEE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qPmPmHWkHV31tYw/01OHVKm8gxaYiHji2m9436HMQ8mxPryC/j9Dt8w+UaWq/6aWV AiBzzB180dAUOxF7K0zHWO89e2P824YINo/Yn5QRHkRkG6CT3gRcAZtqZF3KCrKGbz /Phwgb5C0wmC2cA4+N8PPCp+ZdZ15TXTtdN1iX1E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:37 +0200 Subject: [PATCH v2 01/15] tools/nolibc: arm: use clang-compatible asm syntax Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-nolibc-llvm-v2-1-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1062; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=V6RqjZoNDuMuFSrmOeoNBxIc8QHuAyFjHlyySjNVhEE=; b=SglxSo77Hm5XgbvIdgPvPkKhRNORxL92uzEiid5Q4Ms3oJ9cm3F/JWmUpOFQmCjT8xqvRcw7T 18GOTtzoq2aA+P486EUQqwmXfPCClo5NS1n82PTx+bCs9pPN9kyhuEK 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 Wed Aug 7 21:51:38 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: 13756793 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 71792144D01; Wed, 7 Aug 2024 21:51:58 +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=1723067521; cv=none; b=knnMIgOWUqi5dvombLXPVePAKG6HA7GqBGCPZQH2V7Izx2l6TgOXAbhwJJrAhGQo6qmFwDK0XClxx1Pt4RrFO2zfJTj0SXJEpYnva6mkr1ZnlP73wg6GsMLjWY7x7E6MJTECNV/4520aEFcckZO7rTIPuU6JPAD6pJZKjmJ8KO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067521; c=relaxed/simple; bh=0xwKwk4W4ON043PDHhYy4/zTEWhwuDykJCYQwDWzNPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lbFvO4Mt+lzss6K0aWGYZ0gWhi8VHy0D89xXcvF5oNlmDkSHm53GpvI0a7Uu8RivIJrCsVDJYzw83ctmIOiSXL5taxzGxJ6m7wjzFFuom/u2Qut9FHlwuwlf3n2BaWnqSUi3BfQw41xLwrYsbUt0hSWY/utQUkBAsffiyctFI9s= 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=iQC3gS1g; 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="iQC3gS1g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=0xwKwk4W4ON043PDHhYy4/zTEWhwuDykJCYQwDWzNPQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iQC3gS1gBCZpbFQu2FMqgFKxQ6Fo8bc7wolEfv93c/Y5l9IbGV3IChvQ80bHXAOdY OL6ruHTS/JHDXQMjSfl1KNnTd5Y+LPkBENT0h8CiGW7xM8eAZq+eFm6nfnJpAahJ5w JvSvJJzbQxisTrL7Wy+lJeQo1OngrI9RgC4jejZA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:38 +0200 Subject: [PATCH v2 02/15] tools/nolibc: mips: load current function to $t9 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-nolibc-llvm-v2-2-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1345; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=0xwKwk4W4ON043PDHhYy4/zTEWhwuDykJCYQwDWzNPQ=; b=xN30aahPcj2gQmFgfOB4sY+Er7K5/CDGgL5RksagY7oNvWXVoDXrYw79rBGWZQ38VG8Z/qaIU cbNrnjfZHjGDN0R4o+37G35Ry70sFoAPTwV7XoMBnJUbJ3hJjhO6rs9 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The MIPS calling convention requires the address of the current function to be available in $t9. This was not done so far. For GCC this seems to have worked, but when compiled with clang the executable segfault instantly. Properly load the address of _start_c() into $t9 before calling it. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-mips.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 62cc50ef3288..a2ee77ed2fbb 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -194,7 +194,9 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "li $t0, -8\n" "and $sp, $sp, $t0\n" /* $sp must be 8-byte aligned */ "addiu $sp, $sp, -16\n" /* the callee expects to save a0..a3 there */ - "jal _start_c\n" /* transfer to c runtime */ + "lui $t9, %hi(_start_c)\n" /* ABI requires current function address in $t9 */ + "ori $t9, %lo(_start_c)\n" + "jalr $t9\n" /* transfer to c runtime */ " nop\n" /* delayed slot */ ".set pop\n" ); From patchwork Wed Aug 7 21:51:39 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: 13756804 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 6D3F7156646; Wed, 7 Aug 2024 21:52:04 +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=1723067526; cv=none; b=EztrcYX68IPgMFoZkVmcfBZcNudxjpyJBhssE3URbuNKlKvMda/DINI1ndi2Zi3EwJeAzNidnMoBJ1iYwoquQtluK73/InNSfNPrdCSWK69tYsgwG4er+eBt055CwPnIlt4ajbujsKqcLesReWAxQOH93qO6398Zc6kuotm8sn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=1QhxkVf3uYyMNNfNQNnEZrKfY/yCzs9TKeRStDwW9/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iVfV7dvV3PnR6ImgW0oMMSjLFSNSx/OZv/2ctSJZaa1ge91u7qyyKSbk9eWduGSaTkkTwGTV7bWhtjFlFLTbcv0clGr/VkQ4dC2HIkonWyGR208clBv7R6oeKC+PMHXTRzhreB/B9VL6d/hj7qUEtzouUBxGfEf/IUW3VOl4QDg= 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=brLJN4tG; 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="brLJN4tG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=1QhxkVf3uYyMNNfNQNnEZrKfY/yCzs9TKeRStDwW9/c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=brLJN4tG7nuJcRo7F6gHXUxQxiQjfvO+AXjk9ztVT2xnZvcH60ussVRaEqWbVRR8U 0W6hGqD2vPLqDhkbcIokK71hmWxQbH5OYe3fCy364dPOMNqukQoyRQWPa+Sqqw1Q7I G4AMtforlH8o4cg3abz82e2mUuBZ1xNes1yrpowg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:39 +0200 Subject: [PATCH v2 03/15] tools/nolibc: powerpc: limit 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: <20240807-nolibc-llvm-v2-3-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1020; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1QhxkVf3uYyMNNfNQNnEZrKfY/yCzs9TKeRStDwW9/c=; b=jcxH1PjB1MjV0zoFCKqh0tGskIv4ZpblDDUXgw2mm1q0vOUwYSW+Uf9IkpmOnZO0cJUpt3VFo MFPki47281iDp1sEkACyBLB+Pq4ctoBVzGMddUz3YOkgVpKSyWZiW5n 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 Wed Aug 7 21:51:40 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: 13756792 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 7024E143726; Wed, 7 Aug 2024 21:51:58 +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=1723067521; cv=none; b=mvSMQojSNBa+4qJiB77cAzVoG7H/EqTEj2j1uYBGbUziufEktPwlCsYrmIJHqSksf7y/7kWRvuUu1nOShOtdTeAR5vuIWfRS//yQ3rB0dSEP/K1g0TMECM6lea+AScvgXzlskniD3+slcbjMTcFvC+yc5GP4mTVLGHEyrL2bcU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067521; c=relaxed/simple; bh=JRCvIrZeKoGVVB+qDpKkq3lkyi1JWg3z/lIZUBJjdYc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T2ZUm0bwYJb1b0le1A2Rv65JYwo/hFpKws8fBPDQsEeYD6jZ2+LOwmSP2g/yT4/LcesU+I3+DbxuSVfl3WXKUWHd9i2BCGquXRMIxIG9YGt9oVJacpMStXZBzs/fZ5kq6mBLq+nhiHQ/t68YX0vaQHy1dtNUz0ff/Yz29AuIKHk= 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=D/bl4Z1Y; 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="D/bl4Z1Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=JRCvIrZeKoGVVB+qDpKkq3lkyi1JWg3z/lIZUBJjdYc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D/bl4Z1YYcOictd/WxDrOmtc3spGqJk3hzQvdTja+dQio+c2zf2L1eVuHLTHHA3O/ oxYZRpgNXso8s7aOA85XoWr9+p0intCp6jgS7cuesddQGE2VTtlxHCWQaCACSAmDrx 1euZkRBt5gOh+rHis2VvuBwAiJqKzNjEaGEaDH18= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:40 +0200 Subject: [PATCH v2 04/15] tools/nolibc: compiler: introduce __nolibc_has_attribute() Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-nolibc-llvm-v2-4-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=2153; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=JRCvIrZeKoGVVB+qDpKkq3lkyi1JWg3z/lIZUBJjdYc=; b=/wkLMiuYSIsaYuJj9fz3BErBSruqQeuvNOAEZt+IjrO2AoqL3/w6BTw1s2wbd4chX9JoX//r5 JdoEqsirtMIBIxyAf7hryQMtbPZSbfKj0WpB0bxiVlkij/+VpfKpvS7 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Recent compilers support __has_attribute() to check if a certain compiler attribute is supported. Unfortunately we have to first check if __has_attribute is supported in the first place and then if a specific attribute is present. These two checks can't be folded into a single condition as that would lead to errors. Nesting the two conditions like below works, but becomes ugly as soon as #else blocks are used as those need to be duplicated for both levels of #if. #if defined __has_attribute # if __has_attribute (nonnull) # define ATTR_NONNULL __attribute__ ((nonnull)) # endif #endif Introduce a new helper which makes the usage of __has_attribute() nicer and migrate the current user to it. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/compiler.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index beddc3665d69..1730d0454a55 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -6,20 +6,22 @@ #ifndef _NOLIBC_COMPILER_H #define _NOLIBC_COMPILER_H +#if defined(__has_attribute) +# define __nolibc_has_attribute(attr) __has_attribute(attr) +#else +# define __nolibc_has_attribute(attr) 0 +#endif + #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) #define _NOLIBC_STACKPROTECTOR #endif /* defined(__SSP__) ... */ -#if defined(__has_attribute) -# if __has_attribute(no_stack_protector) -# define __no_stack_protector __attribute__((no_stack_protector)) -# else -# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector"))) -# endif +#if __nolibc_has_attribute(no_stack_protector) +# define __no_stack_protector __attribute__((no_stack_protector)) #else # define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector"))) -#endif /* defined(__has_attribute) */ +#endif /* __nolibc_has_attribute(no_stack_protector) */ #endif /* _NOLIBC_COMPILER_H */ From patchwork Wed Aug 7 21:51:41 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: 13756794 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 C8668145B01; Wed, 7 Aug 2024 21:51:58 +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=1723067522; cv=none; b=AXxIW7KUm0W/IvP9IXN4bX2H6ZRnf7Iv37KX2+OyhUrH7EXBOqPi4++9TRJMXMlX2nbMZJWRBK84rgdKmTnl/l251e5TS0gb2CwM0pGotHZP305N3ob1EB620FAD19oAwuxGp0Gacvf0yWZBrOWx3IKP5kmiXMjG7lVbuReUSUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067522; c=relaxed/simple; bh=qcCzNZ25Nghxp314kg906hORmJEk3Keo6loE3mI2Bqg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N2muhp4DUFFYL/iAvZsajMoYbzdr501e6GLX/PyvRI6Yhb4wNlikPuyfJ72g5pGfNbltJrNAkBEgtLMWErUZepTWrcdmghEkvFg6KM2curbx+E6+j051a0muYXEbK4EDS0zh9ovzg+i+gsMMnI1b2kIhfYYM2pi2gA3LvYFRfj0= 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=kizJW0Fq; 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="kizJW0Fq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=qcCzNZ25Nghxp314kg906hORmJEk3Keo6loE3mI2Bqg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kizJW0FqR6s2abRpwZVzinLfWnuQz+F99iHpjXoyGcCkkYmv4LNMRxEstgEIqDSJe DhgQ6+EEhdgkE5NfocJIhIWJJ9ykU++rD98JYGBtV+4M7uB5BO9YBvOb1tJBG+ySVr +90H0rScB76TWksin3LLZ3MRpm4z1pHO0uHzoHU0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:41 +0200 Subject: [PATCH v2 05/15] 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: <20240807-nolibc-llvm-v2-5-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=9633; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=qcCzNZ25Nghxp314kg906hORmJEk3Keo6loE3mI2Bqg=; b=/B0RKN79ZLUZsQmPt6VRgkC82XdsLsggyt/rA/lMv+nYXKgiD92O1DkmXZgR50QYS/RWW5WqY wYjp1Swg3H8Dft3MVv8LUShaUsvxRHgsHWu1A6+g5iRoTd6JzFCGeVx 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. The macros are similar to attribute((naked)), so adopt that naming. 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..eb77de57e7ca 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_AARCH64_H */ diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index d1c19d973e55..d22aa4d469d4 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_ARM_H */ diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index 28c26a00a762..054babfe41f8 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_I386_H */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index 3f8ef8f86c0f..8cacf03cbdf4 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_LOONGARCH_H */ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index a2ee77ed2fbb..cca3e325ef94 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)) __nolibc_naked __no_stack_protector __start(void) { __asm__ volatile ( ".set push\n" @@ -200,7 +200,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ " nop\n" /* delayed slot */ ".set pop\n" ); - __builtin_unreachable(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_MIPS_H */ diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h index 41ebd394b90c..a5b2a0403a80 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_POWERPC_H */ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 1927c643c739..3b0392353e4d 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #endif /* _NOLIBC_ARCH_RISCV_H */ diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 5d60fd43f883..cfb3956365d8 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)) __nolibc_naked __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(); + __nolibc_naked_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..3c3b703d9b0c 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)) __nolibc_naked __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(); + __nolibc_naked_epilogue(); } #define NOLIBC_ARCH_HAS_MEMMOVE diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index 1730d0454a55..14a854929910 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -12,6 +12,9 @@ # define __nolibc_has_attribute(attr) 0 #endif +#define __nolibc_naked __attribute__((optimize("Os", "omit-frame-pointer"))) +#define __nolibc_naked_epilogue() __builtin_unreachable() + #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) #define _NOLIBC_STACKPROTECTOR From patchwork Wed Aug 7 21:51:42 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: 13756801 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 A7FE8155C8E; Wed, 7 Aug 2024 21:52:03 +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=1723067526; cv=none; b=MrnDajg532Fu9Ma+zw7zydlBGcXFaj01L6QCT4Pdb9qI6X7DPRfXwAeRYvf0Pj3Sx8XTFxJSd3JSOMvwohlpDooKjo7bWCQGsXV6vEtqe1EypKpZGR91b9BL71n5OXBKsw6CV8MKtVgDzv+FF0yUS8CbsYTJS69e4SWm5iRVpOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=uPw5miHYcaSsLeE2v10jPbSAr4/8J4GkU5tRfOmmqv8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gb/rx4nOWV+hnDTru8VMr6D/M9MINhycR8cR1Y38dplBcPIPO8+tGv81l6nnaeU4EsRdmRphFvVryQdgM+ZjLn5Btrv9hlm7zBswVWvvp6eKi+eMGkagrQVJgH2QXW6/9HDeODpx+XImerAYMiGdqcgyjtiZZA+8EC7ajkZR9iA= 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=YzTqhX+E; 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="YzTqhX+E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067510; bh=uPw5miHYcaSsLeE2v10jPbSAr4/8J4GkU5tRfOmmqv8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YzTqhX+EyHLy20A8WG0U25pkwIOoklpR19R1pOzupouvl9KE0AUdT0vhGYNdyqdfL 0zVDoj0FdVcTahQgnDCqby9k8zatM5SfgcTcLP4Lz2iuKo/nPWWAKrrLmztvculOM7 Er02FlMAjCAPhLHQb6jveA4E3xrORTtOFPCTycg4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:42 +0200 Subject: [PATCH v2 06/15] tools/nolibc: compiler: 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: <20240807-nolibc-llvm-v2-6-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1484; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=uPw5miHYcaSsLeE2v10jPbSAr4/8J4GkU5tRfOmmqv8=; b=DKVzOhzwb0h0a9ucmjRw4LStFhFxlBu0FuQ4HwA3b23zXfM/JVxQu6/H5wHkop/4hVO7L0t9y bwkXGNDesQDCBNaar2i9MLSjrWYy047uVn1of7sqWP16bmWKQyF3w4G 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, 7 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index 14a854929910..e4cb5cf772ee 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -12,8 +12,13 @@ # define __nolibc_has_attribute(attr) 0 #endif -#define __nolibc_naked __attribute__((optimize("Os", "omit-frame-pointer"))) -#define __nolibc_naked_epilogue() __builtin_unreachable() +#if __nolibc_has_attribute(naked) +# define __nolibc_naked __attribute__((naked)) +# define __nolibc_naked_epilogue() +#else +# define __nolibc_naked __attribute__((optimize("Os", "omit-frame-pointer"))) +# define __nolibc_naked_epilogue() __builtin_unreachable() +#endif /* __nolibc_has_attribute(naked) */ #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) From patchwork Wed Aug 7 21:51:43 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: 13756800 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 B59E9155C8F; Wed, 7 Aug 2024 21:52:03 +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=1723067526; cv=none; b=LXy9cm3yiqSjNSSrn+x2MYrJpFYqdOlYrn4oBYbB8Ri8ARwpBsCroN+kgWc17X5KzXS/eMaCjsR+6ruqoxREf8BIooqBs3WPaco1pf2czlm3wg8XWj/31ZdqIuXewNvXv9YIKKZMPpnjEjFHqvw+tDBMAEO27n5/2RH+uC6uPk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=8l0Dnz5Yd/S2UT/jNbx7vp2HyK4QJxhKjhlILkEgS5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r86BQBmcyY/MGZW2++dUhPs5ECO1TqspP4PnS3N7LKE6qe6lohHEZL5rNECoOBUA3/3Q8AaxekKe7159Jfl6FcFC3kqA88P4jQ+w29SD1WsB28qNqSV6zuKJr+ucvy/qKJk+5ocUK0zAYLQ/L2se6nv5gly/QHNuK8lDgc48Bjg= 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=OuSRhXuz; 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="OuSRhXuz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=8l0Dnz5Yd/S2UT/jNbx7vp2HyK4QJxhKjhlILkEgS5o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OuSRhXuzVjmlrXknPY08I2ptU6++PxRBBS91mNcZq7ogAGbfSZmXrE6v70Ib31B5s NOPhX02Tzez3yGPO3aAM/zA3ky5kfmclFHMN1+KouE1xr1a2VCBdsj6mp1xAEhF1mJ U+jOC2gbJWkjdDpQHn4op/vNbgMrXw5vGHhE8FMc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:43 +0200 Subject: [PATCH v2 07/15] 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: <20240807-nolibc-llvm-v2-7-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1054; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8l0Dnz5Yd/S2UT/jNbx7vp2HyK4QJxhKjhlILkEgS5o=; b=YG//gAYehWzBTZAjqtDTQ5VQk1MvrVvaJIjYk32f6GxA0Twj8SycU/17qjKf0xNVO31sveDpx 850wxVZhMsrD+kqMNTi2/rvmETJvh7S1cWLUnOs5Z1hwkHzx+yI70nD 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 Reviewed-by: Shuah Khan --- 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 Wed Aug 7 21:51:44 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: 13756795 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 D25BA15535A; Wed, 7 Aug 2024 21:52:02 +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=1723067524; cv=none; b=qXbp+o4crhINrU1+rUTSgbHc8Cj1V+i6Z4JtYaTr6kPg/s6FoWUWMkR1f3rlwGUEvToG3t98aJoAsFXXW8wYfdmCh/cyamSIK7mVzJ6jRKtGcNsymHC5N9taLdUfvBA94K1Oeq7L8QQV6IYH3NcrdHZkFKeeDFqBEOoWeN14o5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067524; c=relaxed/simple; bh=obIjHsolXNXcLTedUP4pqEyIcSocTNAfNvlGUro4FYo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A7bKDRBffSpZQq7AxMCDvrW9lIiXOqzjHPrEkyEy8fJlKeegniWD7LInACKFWjoW1lOaBvY1VMFMLsvFqeg7FGMrYqQAVfhOsCWAFF8VDuYvkDpuMRehG6dQiLTXahYUmNB+oGpZu6RbfbaipqEHmY3Q0fHTF8cumhQGG7x9nKE= 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=fa+dV+c0; 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="fa+dV+c0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=obIjHsolXNXcLTedUP4pqEyIcSocTNAfNvlGUro4FYo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fa+dV+c0Tky2ez/aJ5ChRq8pNxGCmZb0wVpBYUwlMtIbW5oJ/X2SytykQY+v6TBXf gs7iDXV4MuA3Is3ZZNDwlMKh4B2md4D0E+1Ml436co3hvM6YUvttpeVN911ujxx0X3 3hP84CzKzL46sDdAbqeeDy3gnB7+QoJds41MvHqA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:44 +0200 Subject: [PATCH v2 08/15] 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: <20240807-nolibc-llvm-v2-8-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1257; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=obIjHsolXNXcLTedUP4pqEyIcSocTNAfNvlGUro4FYo=; b=z9Y10TL611sG1brS8Kg1Uktqf7SPz0K9do0wzKH+GkueCbd/6HYsFORmh8DOpKipNc93nyP/C ErqGrlIneIcAtWXhpBhaWG7xljH1wYzkIDtjKCQBCwxD9RT0nvEXenG 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. While printf() from nolibc gracefully handles that NULL, it is undefined behavior as per POSIX, so the warning is reasonable. Avoid the warning by transforming NULL into a non-NULL placeholder. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- 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 Wed Aug 7 21:51:45 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: 13756798 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 D25FD15535B; Wed, 7 Aug 2024 21:52:02 +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=1723067525; cv=none; b=s3/BbHanLE0x2nlvg6E7TP1f2yT7t3LplvosRxwYlF1tKOYS00l7CgS+a/3+6JI1PpwMXlq22z6Z5On4xRRcHyZpnhchmFOje+javNSTgDHh164PATg5DvayhTTCf6hkz4F5bplLjnoSUqn43TEUehvb2TZd5Wp+S23tsublKxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067525; c=relaxed/simple; bh=4W7HZDJOblZEcLHcrQM9iEEvp6UnFoiUYk+r8TvueIM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jZvicdwd21WWWUDtjWds7ujmIelmdaWReL5Ql+QGy+kByMwghl5pBCDVJyazzWiDvc8QUEo1KhrmOEIFMBUFsuKt25oF0d/5fqkdrVVO3rk8e2JYS9aOdEhYW9c5T+u0Yyck6FtUznZ7e+agmtnlczRyPfs90uhUJHiHaoEj3rQ= 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=DbFbC10z; 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="DbFbC10z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=4W7HZDJOblZEcLHcrQM9iEEvp6UnFoiUYk+r8TvueIM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DbFbC10zFm2X+xFl7Q9Uh5H3YxH9Pjv3JWTZYZWg4qvNuJYqBGOJOk2LGUEyFdxMP GRljcMNfCZAm0SCXkMz8r16gK1CMsUj+ypmMZSnTdBfNaMcPLpTLxqGw9NKsA97MqP fVddThwjstXUf2d43sjWurg0Q1x/XElMQkmbTnC8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:45 +0200 Subject: [PATCH v2 09/15] 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: <20240807-nolibc-llvm-v2-9-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1795; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=4W7HZDJOblZEcLHcrQM9iEEvp6UnFoiUYk+r8TvueIM=; b=jj2bplu2tkULkYur4/kcZD60eor02SnqztYgKFNXT1eUQerKP5wdcqItJiQWADhlDfVOr4oqH gQHcOC42JMQAmI3QnBscOc3gzNvNXq9Aulo6Gr6vF61owPi9Z45gJKP X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The nolibc-test Makefile includes various other Makefiles from the tree. At first these are included with relative paths like "../../../build/Build.include" but as soon as $(srctree) is set up, the inclusions use that instead to build full paths. To keep the style of inclusions consistent, perform the setup $(srctree) as early as possible and use it for all inclusions. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- 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 Wed Aug 7 21:51:46 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: 13756802 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 6F243156649; Wed, 7 Aug 2024 21:52:04 +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=1723067526; cv=none; b=V7nBDIdVmr+CZ8kwqLuoZw/KABpLwPXx8Fh5Eug8eFUc6ke2Zc8GF3Mo5bqGofGwJA/6T/Rh6ru/zpYUOWz/G8pHrV5vAD11s7sS8ueI/yi03KkEXiwe2wgEjl6nvWRmGuqtRSSAEMUYkeiJ7FQ6ac8c+WQu4BJlO+7YMwvFmYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=CvIO1V+EWLk9gJaEt19CwmObVNz50d2RnPOeITjF7XM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=toxqQxD0Y4EbSasNcdETKiYa4N7/BAyEjqsu4acG6EChcKqgF4dVi9bErATXPdA9pMruBYE1FcTWTTDkV1GgDazUFppOhUSLXFRB4tieGd/93RwOeMjDliXVbq4lvQJ2Ah3UJVBT/yukHghs5uKjjrh5YXFdx7lgHdwbOLiYb0Y= 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=K9maKGHJ; 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="K9maKGHJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=CvIO1V+EWLk9gJaEt19CwmObVNz50d2RnPOeITjF7XM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K9maKGHJcx2OjpJtmDvBq6j2d4T5uQwyTbHTd1Zbayec4LbS4GD45fnpMiQCbLKuO sYMwAy7r+Ah13ar007qrXpawFGWUsz7WL/xLYyZz5WUEkeqcxFId7lfOpfcB7SrOuy EyIPN4nvQ0FRACGowpfbh7hocCx/L+Q2+0A5jta8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:46 +0200 Subject: [PATCH v2 10/15] 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: <20240807-nolibc-llvm-v2-10-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=2298; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=CvIO1V+EWLk9gJaEt19CwmObVNz50d2RnPOeITjF7XM=; b=aIYQwTZfI8AxgslY0Uhi52TonR+hoTgGqjrxXg0Ymu2i831yZFf9wa2ETKbNoLxIUkYh/tAjz wBclZdA6YIVA4OsdAlqjFO/dSo2ftC+OGMdtwe6Z1cQOVi0pnBwAnc5 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. Makefile.include is currently used to handle the O= variable. This is incompatible with the LLVM= handling as for O= it has to be included as early as possible, while for LLVM= it needs to be included after CFLAGS are set up. To avoid this incompatibility, switch the O= handling to custom logic. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selftests/nolibc/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 803a4e1bbe24..cdff317c35f2 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 @@ -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 Wed Aug 7 21:51:47 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: 13756803 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 5CD3A15625A; Wed, 7 Aug 2024 21:52:04 +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=1723067526; cv=none; b=crB2R/P9PyjotWxDuMyO38q8+yLhmf//kjeTAmAiEuiSQjJ2J1tT2CASohE+ceNBPg93vbMNX8jm8WbeSz0ER3jALAzyK/YSU17B5yLwrn/tMo+GxAO1UO7Kj8ygDShJbG6NIhurBkjpbSdomQxSnuz6AivKIuRupoc2jHN4I8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=mzJqvggvf/O3hGt8YR0AaA0XozV76zGpeEuCI2JjtjI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rlj834eqhdvuPW7SfwCURiKzyOhgOagGZyszs2kYnV4DOtV7ElcejN59bqipcBDJCzJD4gtphmN3JhlX3qJCsWYR8ig2tEIDVfDme9FimAvgzhqMlc56KUTVQC0NSH1wfAjyDUN+1PHCVRS3gfXfuGV08+63xf8y2ZxeaoTRBfs= 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=Obe1Hv2A; 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="Obe1Hv2A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=mzJqvggvf/O3hGt8YR0AaA0XozV76zGpeEuCI2JjtjI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Obe1Hv2Ai+nk+pEozj3wMuc6lcmV5n+cym9W2xXFJJd8tMCxuz0vt4jaZ6fFBv8xj d8qni8LpyUbgMs/8D/3BWiuANc/nnmNF+nRUfh/40LPQRFAG6HEb8OFDmd3rqhzMU8 UiStyxIiMLd0Np9YpjZJCUZ63f63+yzqcT/DOJug= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:47 +0200 Subject: [PATCH v2 11/15] 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: <20240807-nolibc-llvm-v2-11-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1451; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=mzJqvggvf/O3hGt8YR0AaA0XozV76zGpeEuCI2JjtjI=; b=6mt2mDEcgMwvjyijTyBBuyriPgXEhcN+zP/t4jRZYDfwWBdq2fs+xW0A4e9T8oSM9AyomEG6h ntdp3d4N7UPAMEfhMTQ3vCHVryVKEFHcJb/3eaRi6d3Q5rB+f2geH+e 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 Reviewed-by: Shuah Khan --- 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 Wed Aug 7 21:51:48 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: 13756799 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 225CE156231; Wed, 7 Aug 2024 21:52:04 +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=1723067526; cv=none; b=gW8SC1Z6SyCasotzNU4fhpAS3EAC8O7F351c6tY9eooKavUVe3jMpRtS+5VD/8cJuD1l1YbKfRqD5wQ0DvgfBktMS/toXt+vIk1pO0y9UaGfaYebURewDzHol6RZbkwvi/QHBJJbMLMqH0cMi7GY90q1PVnpBg5XO4S0p6bDREM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067526; c=relaxed/simple; bh=dLS4bfcDWOs0R+HPnp4+vgff6vztKn00nqYdkqkwdT4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JpOar5knuyJv9JOrOqUVM79+ZtfrbRec9FztaxkK8DYDilccSAdEI7ftCOeNBQhkdB+4v1UWIxo9rCY3LJRshEQcAjTaucsN1cwrI9iZkwEJ4wXRl6cPjecTMN9yM4l3ybpo5H3a+6cmIVqp2OYshRc8gQOyNH2Db+oI3Ywdbcg= 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=crgHlVmW; 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="crgHlVmW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=dLS4bfcDWOs0R+HPnp4+vgff6vztKn00nqYdkqkwdT4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=crgHlVmWHC/eG7mCT6h8ZQlQszouDUnb/9agPMvgIZZ0JYcgOJjC/IkGm1g3WQAvP RuCHgEp9D5x0cc3zctVHC0GmYbTIL0H/+j5NjU7mgcr7CsEIUEi2ZtUkfSuf342AE5 3N5sc+5rJjWw5toeuqBJtQUgmutTYHQdQOObSWGw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:48 +0200 Subject: [PATCH v2 12/15] 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: <20240807-nolibc-llvm-v2-12-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1538; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dLS4bfcDWOs0R+HPnp4+vgff6vztKn00nqYdkqkwdT4=; b=nw4sb5Q5OsrOLomtyTEshN7ERBLtc7pTpMwseR96ql9bXAcV//0mTezFtCiZpP3lBPqAHhUO4 KiWWHpZq3HwDXi3CkxJgCTIcj3mnMQVrNGASYk60Ivt+UaqrBR6r8fi 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 Reviewed-by: Shuah Khan --- 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 Wed Aug 7 21:51:49 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: 13756797 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 7DEE9155A4E; Wed, 7 Aug 2024 21:52:03 +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=1723067525; cv=none; b=BwX5P8duOg44267MBqz9d6GFUuz5+43X8hBSplqAcMBWlbwzHxIGJ7F3LP7SPIXwLtolshYeY/IXLhIKAm8EGHVo7AxC0uQqWCaoBuRNTdmNLLD7crLONA5COeWib+IxUnWY6bvs2FIjn58RXsnGgne6LaMFic5MCdBiUbT3Qm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067525; c=relaxed/simple; bh=JtLEcuDc7sUI0OHNtKc1zClGfVywsj/5MGDGho6L+CA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=da3+TuXSCXlIfqoEoY50JsbRinLvdSTCnWPHGD32XNVMg7FCVUJGvUQJYDn2+6Eq+B9Z6XsvwUUjx44vgH7KCFk6JPK/x6wi8acDXra/ISHlIaGjCFrpHSn+1FqsAVMG3N7rNyS2wc3WtkbwM8QNmdMaO38wjzaMSSj3S8jpSPg= 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=Tzqwg2FA; 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="Tzqwg2FA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=JtLEcuDc7sUI0OHNtKc1zClGfVywsj/5MGDGho6L+CA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Tzqwg2FAxUJ3BZb/tDBVlqqS1VhcSEZcuwq6MWSnjRbRI8WjPrLAWEo3lo19RxdI5 e84kKS5jtbGpYEUQWX/8EHdUUppuZgRl9gPNJQhfINUVheDj8rD+9vIV+VOrw+1viS XiUOG31ct3gWbnj9ViiXYVD+RnIp9xHQFq080IRI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:49 +0200 Subject: [PATCH v2 13/15] selftests/nolibc: don't use libgcc when building with clang Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-nolibc-llvm-v2-13-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1797; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=JtLEcuDc7sUI0OHNtKc1zClGfVywsj/5MGDGho6L+CA=; b=lZd+zdKU0xX5jts8qZF/ixTsYcq2SUyAVAuJLSeaEVXLIZT/M7/AgAmGNYusymJlBPqJNthJo FpMu+BanZBxAl0luNOMqjVsan0GHHRLfl/S6mwgkCUQvcVuMxYm/8R+ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The logic in clang to find the libgcc.a from a GCC toolchain for a specific ABI does not work reliably and can lead to errors. Instead disable libgcc when building with clang, as it's not needed anyways. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index b8577086e008..f0ce8264baac 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -157,6 +157,13 @@ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex $(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA) LDFLAGS := +LIBGCC := -lgcc + +ifneq ($(LLVM),) +# Not needed for clang +LIBGCC := +endif + # Modify CFLAGS based on LLVM= include $(srctree)/tools/scripts/Makefile.include @@ -209,11 +216,11 @@ sysroot/$(ARCH)/include: ifneq ($(NOLIBC_SYSROOT),0) nolibc-test: nolibc-test.c nolibc-test-linkage.c sysroot/$(ARCH)/include $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ - -nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test-linkage.c -lgcc + -nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test-linkage.c $(LIBGCC) else nolibc-test: nolibc-test.c nolibc-test-linkage.c $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ - -nostdlib -static -include $(srctree)/tools/include/nolibc/nolibc.h nolibc-test.c nolibc-test-linkage.c -lgcc + -nostdlib -static -include $(srctree)/tools/include/nolibc/nolibc.h nolibc-test.c nolibc-test-linkage.c $(LIBGCC) endif libc-test: nolibc-test.c nolibc-test-linkage.c From patchwork Wed Aug 7 21:51:50 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: 13756805 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 46F1E15A4B0; Wed, 7 Aug 2024 21:52:05 +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=1723067527; cv=none; b=r5PvLLzEezrcqBfDUV+u1x/imzSBXpZkuj9NiWeWprOgfAK6orHAdzujkwIMZbhyZcDPHvHzjFhkPKOlW4qg7WiPtGH8ACtpc6uvGbHSfXV4dnM0+7fMa2gP2+uPw5Y3ABmBLnAKKz/5B9EiMjOf0slrPqeP9BMIyBK8lM/Iao0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067527; c=relaxed/simple; bh=QNaY7kJFMuM3ZkGNIHxAYKHUdeofTLZIOkuPKOo4EXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k4B7rJMp8JfxeC00Rw2nwqO9ULcrCyvlIeNmpW70cWzzb+iuvX7phh71lwGMPOokIWJvzVngwKqMnl/O9xv92aCM8RJ+wKs8Fwua4pikFamS0vBfGcVORUdAkonW3dQ5c4PgBNm6gcmADr33Ciixut/NuXbcQvXugCaWsAjWPxY= 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=q6VIE1wh; 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="q6VIE1wh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=QNaY7kJFMuM3ZkGNIHxAYKHUdeofTLZIOkuPKOo4EXs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=q6VIE1whSznrFdxsRqK0MYRIhpO4HMdfTemBTUHFdF7ZAPvUPssVvZm8IUtRydZmN /V8+mAP1CaV5MvWDQLGjg4H8iz8MNCDL/CuM71swEv9VdNIR/6NQrcXjqbCCIEK5BB nEEIgEMg4dtz5fIcg2OyRyTRwDIZ3JPmIQ7qiqLo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:50 +0200 Subject: [PATCH v2 14/15] selftests/nolibc: use correct clang target for s390/powerz Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-nolibc-llvm-v2-14-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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=1723067509; l=1173; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=QNaY7kJFMuM3ZkGNIHxAYKHUdeofTLZIOkuPKOo4EXs=; b=yRql2CS1JaYly+HZvycEqBSi9NWWl/xm4ctiJUhHLAbiLSO5EWansfaH4XnPb5qdK2HdyKdXm 7velTRzdn2NAjC8pEExFKk2dy/nzOrHYMtYoncnWxLtjs2wDReBi3zt X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The target names between GCC and clang differ for s390. While GCC uses "s390", clang uses "powerz". This mapping is not handled by tools/scripts/Makefile.include, so do it in the nolibc-test Makefile. 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 f0ce8264baac..8de98ea7af80 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -167,6 +167,9 @@ endif # Modify CFLAGS based on LLVM= include $(srctree)/tools/scripts/Makefile.include +# GCC uses "s390", clang "systemz" +CLANG_CROSS_FLAGS := $(subst --target=s390-linux,--target=systemz-linux,$(CLANG_CROSS_FLAGS)) + 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 Wed Aug 7 21:51:51 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: 13756796 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 7DF38155A56; Wed, 7 Aug 2024 21:52:03 +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=1723067525; cv=none; b=r9qXUgMA+kkNbtCYj555ZxH6c2wKGOgkoa5jxfa2Le8g1ywUiWfzriBlAUVPAuMWbyPwpYl9VnUgxuIC97vktxLsFXU0HAVpnyRv2+npEoNGvtUXbw5Rr5L3Cfc48ivWy5kZkTFPfJ6gkh4A6lWEqBkjIAHqCul0Gw8rjtSPFDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723067525; c=relaxed/simple; bh=oRgMb/2rEclPwfWBKF/mGGZvwsZktVlEyUFTfYwp+Po=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VBEumIOjwp0kX55DTL7qaZ+eS7cK8VSbXCCDPufEatP4TAFglnIJFT+o12IK7n/37TsoGxLpDaVBREvBp0j5EIhw+jJaLisSlEyfqQe6rvWjdJfvIdjG0VxRYFzyqDLvvrqrEgA87qm19idf6Bd7gqEwuI90dOTPqrpa7S6an9U= 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=dAkQyPKy; 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="dAkQyPKy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1723067511; bh=oRgMb/2rEclPwfWBKF/mGGZvwsZktVlEyUFTfYwp+Po=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dAkQyPKy4uwTVzuytsCYWt21hxmOmlF8kx7127JJvxZ7RhnacsTWZ8RlR1nkD2kyv Ml7pmqB4OOI/Iz4vq3/lBK9nTXDAiaaNwMpW74/+7Uz60drSHPw4FSUOHMVHwSu+Gh x9dvitXW6zxhiolwzicQV9j2UgGkeWEpyJRM6zLo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 07 Aug 2024 23:51:51 +0200 Subject: [PATCH v2 15/15] 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: <20240807-nolibc-llvm-v2-15-c20f2f5fc7c2@weissschuh.net> References: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@weissschuh.net> In-Reply-To: <20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@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?= , Shuah Khan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1723067509; l=1785; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=oRgMb/2rEclPwfWBKF/mGGZvwsZktVlEyUFTfYwp+Po=; b=V3kzjxBkkhKxs515hjrbUo+Lgi32z8Bw+QSJbS3AbkLsRgF4IaRzPkdKqTU0X83jOANjysvjW CGH07nGVaD2Csm/kQQD5DISrRV0H5di503S9Uv4evzBzSoMEF0XX3KM 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. Signed-off-by: Thomas Weißschuh Reviewed-by: Shuah Khan --- tools/testing/selftests/nolibc/run-tests.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index 324509b99e2c..e7ecda4ae796 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 @@ -143,7 +148,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