From patchwork Mon Jun 19 12:24:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 109967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2977323vqr; Mon, 19 Jun 2023 05:36:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gyavtRLBdTYgYHzjN+sJ86bc97gp3zdo7i2Ik8/9XlVewPqfUrn/40GO0mHPod79jTsYY X-Received: by 2002:a05:6a20:7d8e:b0:10b:e88f:598f with SMTP id v14-20020a056a207d8e00b0010be88f598fmr13626269pzj.51.1687178214055; Mon, 19 Jun 2023 05:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687178214; cv=none; d=google.com; s=arc-20160816; b=QkWK4CfjOR8oov7eWYa4fr6NY/MzSEtdmKMj2JfukEERmU8cyK4WKNFHlWMEP9M3KI eWJ4DwbKTnPkuaVVlV55CwYmZxF+0Q2Qnboczs2M0SCOYmdMjV49VCmTUdxfHTurZXp7 b6SJ69O5bxo/yjIO5hPEi5LRl10QPDurOAZi6KW2xWxPUT4mWoI+SSAx+v/rTVLh2ArG dKRjbpy9x0Uzy5gG0FcUit9nZeyGRQakutvd48vgvIky9Gd+XVl4vzwceFrVDMmulKa/ yepvv+0q0EIOAjFktWclfGrAvsYHToSBW+tqsh4kjRTBPH33GC4mgskwoNyox6ESRj4P C+zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=xzOaark2jEuc2CPE3LCabO5aJoOOhLYoYtWAvPA3YWs=; b=0+wPLvbArVlLRZ8e2KGK5FuQUP3AP3iOx+kZ8rhfrnpinHeWnOl3tEJ8VoVQhELmmJ 7driBgWkUG9o3fJKoYB+HqtZynt1IV2AEB9BXZJYTvOBGbFZjRN10yIjIdYHMbm74EUY 2Fz+9jEv70KEMmnony8pG6SCAegv5gQ8xhbXL+Wml6W0JEq8nvcAVVxnjdmfRmf7FYzN Q/6anYJhstrlA056GE5RnM6JRzW2m+GobdeCgBHQCa83U44PKmOTBQuadVo4XrTnkt8s 5BG6JKHEct62z9cAn+RrmeYgXR0u3XhYbwfy5UFlXy7QJ0bkm+vTR7hzNZE0xa+GMSW3 A2tQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y72-20020a638a4b000000b0054ff8291781si9521623pgd.349.2023.06.19.05.36.40; Mon, 19 Jun 2023 05:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230511AbjFSMaZ (ORCPT + 99 others); Mon, 19 Jun 2023 08:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjFSMaY (ORCPT ); Mon, 19 Jun 2023 08:30:24 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0D5E62; Mon, 19 Jun 2023 05:30:19 -0700 (PDT) X-QQ-mid: bizesmtp73t1687177462tlqf4j6u Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 19 Jun 2023 20:24:21 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: VbOeDQvtdXORok8YaoXRnAMACRibjaa4Zvbrj15+WMLSwufmkG9LMAdyY8Ein 2OwxfOiDDC0BifHbTdxZbJH1mljpItWBnPOr5JhNTv1Ya59YgaKMc6CXWsTmjhXxKIT8Qqp JjGYsjnMR5XlwjUElOlkjPwSSa135JuYzIIoYGtsDYvqSTWKooG3Fn4Bn6OZi2rO2Xse8nZ P2wJLMQDrGvO+iDQiiea/Gqh2kxuXeioFKdrwfUqWdkV59oboGAlAnMVF1icF8qLtBhCyrl TkNwi8bPvI+9G6E6l1biDAbQqd8j1p3c/djFR1455mi9OGMsg5xSJhywwDPUrbed0dCa6jk XvdNHbwwb+m9QbRjJJXJFZqoOEc87yWDomOKuz5AD3JdDPe4pm4kEek7QVXCA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1937257225110562742 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v5 1/5] tools/nolibc: fix up #error compile failures with -ENOSYS Date: Mon, 19 Jun 2023 20:24:15 +0800 Message-Id: <1a823ba7b250ba5190f802dfc4428d4e248f71b3.1687176996.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769134583212103057?= X-GMAIL-MSGID: =?utf-8?q?1769134583212103057?= Compiling nolibc for rv32 got such errors: In file included from nolibc/sysroot/riscv/include/nolibc.h:99, from nolibc/sysroot/riscv/include/errno.h:26, from nolibc/sysroot/riscv/include/stdio.h:14, from tools/testing/selftests/nolibc/nolibc-test.c:12: nolibc/sysroot/riscv/include/sys.h:946:2: error: #error Neither __NR_ppoll nor __NR_poll defined, cannot implement sys_poll() 946 | #error Neither __NR_ppoll nor __NR_poll defined, cannot implement sys_poll() | ^~~~~ nolibc/sysroot/riscv/include/sys.h:1062:2: error: #error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select() 1062 | #error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select() If a syscall is not supported by a target platform, 'return -ENOSYS' is better than '#error', which lets the other syscalls work as-is and allows developers to fix up the test failures reported by nolibc-test one by one later. This converts all of the '#error' to 'return -ENOSYS', so, all of the '#error' failures are fixed. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/5e7d2adf-e96f-41ca-a4c6-5c87a25d4c9c@app.fastmail.com/ Reviewed-by: Arnd Bergmann Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 856249a11890..78c86f124335 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -124,7 +124,7 @@ int sys_chmod(const char *path, mode_t mode) #elif defined(__NR_chmod) return my_syscall2(__NR_chmod, path, mode); #else -#error Neither __NR_fchmodat nor __NR_chmod defined, cannot implement sys_chmod() + return -ENOSYS; #endif } @@ -153,7 +153,7 @@ int sys_chown(const char *path, uid_t owner, gid_t group) #elif defined(__NR_chown) return my_syscall3(__NR_chown, path, owner, group); #else -#error Neither __NR_fchownat nor __NR_chown defined, cannot implement sys_chown() + return -ENOSYS; #endif } @@ -251,7 +251,7 @@ int sys_dup2(int old, int new) #elif defined(__NR_dup2) return my_syscall2(__NR_dup2, old, new); #else -#error Neither __NR_dup3 nor __NR_dup2 defined, cannot implement sys_dup2() + return -ENOSYS; #endif } @@ -351,7 +351,7 @@ pid_t sys_fork(void) #elif defined(__NR_fork) return my_syscall0(__NR_fork); #else -#error Neither __NR_clone nor __NR_fork defined, cannot implement sys_fork() + return -ENOSYS; #endif } #endif @@ -648,7 +648,7 @@ int sys_link(const char *old, const char *new) #elif defined(__NR_link) return my_syscall2(__NR_link, old, new); #else -#error Neither __NR_linkat nor __NR_link defined, cannot implement sys_link() + return -ENOSYS; #endif } @@ -700,7 +700,7 @@ int sys_mkdir(const char *path, mode_t mode) #elif defined(__NR_mkdir) return my_syscall2(__NR_mkdir, path, mode); #else -#error Neither __NR_mkdirat nor __NR_mkdir defined, cannot implement sys_mkdir() + return -ENOSYS; #endif } @@ -729,7 +729,7 @@ long sys_mknod(const char *path, mode_t mode, dev_t dev) #elif defined(__NR_mknod) return my_syscall3(__NR_mknod, path, mode, dev); #else -#error Neither __NR_mknodat nor __NR_mknod defined, cannot implement sys_mknod() + return -ENOSYS; #endif } @@ -848,7 +848,7 @@ int sys_open(const char *path, int flags, mode_t mode) #elif defined(__NR_open) return my_syscall3(__NR_open, path, flags, mode); #else -#error Neither __NR_openat nor __NR_open defined, cannot implement sys_open() + return -ENOSYS; #endif } @@ -943,7 +943,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else -#error Neither __NR_ppoll nor __NR_poll defined, cannot implement sys_poll() + return -ENOSYS; #endif } @@ -1059,7 +1059,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva #endif return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); #else -#error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select() + return -ENOSYS; #endif } @@ -1196,7 +1196,7 @@ int sys_stat(const char *path, struct stat *buf) #elif defined(__NR_stat) ret = my_syscall2(__NR_stat, path, &stat); #else -#error Neither __NR_newfstatat nor __NR_stat defined, cannot implement sys_stat() + return -ENOSYS; #endif buf->st_dev = stat.st_dev; buf->st_ino = stat.st_ino; @@ -1243,7 +1243,7 @@ int sys_symlink(const char *old, const char *new) #elif defined(__NR_symlink) return my_syscall2(__NR_symlink, old, new); #else -#error Neither __NR_symlinkat nor __NR_symlink defined, cannot implement sys_symlink() + return -ENOSYS; #endif } @@ -1312,7 +1312,7 @@ int sys_unlink(const char *path) #elif defined(__NR_unlink) return my_syscall1(__NR_unlink, path); #else -#error Neither __NR_unlinkat nor __NR_unlink defined, cannot implement sys_unlink() + return -ENOSYS; #endif } From patchwork Mon Jun 19 12:25:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 109968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2977930vqr; Mon, 19 Jun 2023 05:38:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eBZ2AHimLOjXVU3GDZOyyu2vloPHZf6QrG0+dvFZdZTejPK4sHWkuKzOPqZFD0BJauN7i X-Received: by 2002:a17:902:d2c6:b0:1b0:295b:f192 with SMTP id n6-20020a170902d2c600b001b0295bf192mr12899131plc.3.1687178287233; Mon, 19 Jun 2023 05:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687178287; cv=none; d=google.com; s=arc-20160816; b=pprBPbjzl4FXQg+108bkiV4Z1JU/32KoOPvORsnYeTBzWQsO3TPtJ+jREzaB4CQQ/q UqbpIfVb77ePJL1SlkdGGsQzvhA3UimgLmMsCky3OQWId2Mb7481TCR93zkt7dV2ZNCH Gd9ObdBOS8rl8WUwAhnt3eww+Jtqj0psCz125AqhoG04Feh8EBGP1A3o7l9CBpilnxuE cKGQdlivFUjcONQ282Pm3oasSe7XwqyRc8YMnvZMnRAjl9xWLkNkedyasd6CEM5uOhsj 1l28ALVcMIOBpZ2fEdCOQ4jAyxCsQvEpceCKsD2/19mIDWDcqkc8474Z5rtEiOUyteDB 3A7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ePtgTq7zWDJJxTplnv0FmshqRJXn3LxvMTU2uvRoxos=; b=dJ+9u0yeICfwIw9DJXU4aSXHkJ3ODVKku6sPgqUHN7OcGSFypdxtwVec3dT4/goDzU yWTSegbSP5QyFTv3qHeDc9AUsXv6rytx6v8mp7UpshhsYgtWhSxlblvhUxzJLrA4Srsi wameNMg4ZCiIJoZk1sM/rFyaUnlEkK/3nFDXj1hVQezUm3aRtpBCAe50ckMTjcJEjsEz CUtaqLYrbp5QNpZRs6uf1QLYSQ85tzDqdukJX8izXBDD9ti9cZkd9Qb1egtqYXIqTf5M nwUjk0pi1P/UWMLxoTiecnas69A+n9px94Uj+ijcGELE7vhienX2Zcrms0umsxGaVv9t 8hZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a170902da8f00b001aaf7a9d7aasi17062517plx.126.2023.06.19.05.37.54; Mon, 19 Jun 2023 05:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbjFSM1E (ORCPT + 99 others); Mon, 19 Jun 2023 08:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjFSM06 (ORCPT ); Mon, 19 Jun 2023 08:26:58 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6185C10E4; Mon, 19 Jun 2023 05:26:32 -0700 (PDT) X-QQ-mid: bizesmtp71t1687177555tdy8glxa Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 19 Jun 2023 20:25:54 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: pmyeiOl6PGloDyKgJ78LuhdCTqCBX14MaQlxSqWSUM+fBWGJ1go2bQbmC59zr ZOC1Hp/gCPLtjMu7oHsZfH41/31fX48DKVY/lWdsBds7A1tYEynCyJaUHGfuquUlL6q8gQq ZOEeIwhtVdjgOAZdo0sja+Z38C7WlcJD+q1KknwTqaXtPukFvLcMgRx23AA+v8vCstIciwA 3feXF93xbVOZlOq7HuDhut33K4nqNsTxSI8ewXH9QU/BzaYcez48Cc++oXiXl0w23ujad+H U/31uRTiGsETodb0LQXimJx5VA7i0n/vg+Zy7/EsjEaDRgM9jkmxslgVZOo2yNGzuzOWoNd MhpflHuVQaot1bisFskuxQnRFInxDvfOfWiR2c4yzXLtOUuJDpdOZQmxGW/D/Zd00E6Fvnx X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14529842388647042885 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v5 2/5] tools/nolibc: fix up undeclared syscall macros with #ifdef and -ENOSYS Date: Mon, 19 Jun 2023 20:25:47 +0800 Message-Id: <8c431e766a15d9e08755cd50d550de2a474e7a95.1687176996.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769134659681988602?= X-GMAIL-MSGID: =?utf-8?q?1769134659681988602?= Compiling nolibc for rv32 got such errors: nolibc/sysroot/riscv/include/sys.h: In function ‘sys_gettimeofday’: nolibc/sysroot/riscv/include/sys.h:557:21: error: ‘__NR_gettimeofday’ undeclared (first use in this function); did you mean ‘sys_gettimeofday’? 557 | return my_syscall2(__NR_gettimeofday, tv, tz); | ^~~~~~~~~~~~~~~~~ nolibc/sysroot/riscv/include/sys.h: In function ‘sys_lseek’: nolibc/sysroot/riscv/include/sys.h:675:21: error: ‘__NR_lseek’ undeclared (first use in this function) 675 | return my_syscall3(__NR_lseek, fd, offset, whence); | ^~~~~~~~~~ nolibc/sysroot/riscv/include/sys.h: In function ‘sys_wait4’: nolibc/sysroot/riscv/include/sys.h:1341:21: error: ‘__NR_wait4’ undeclared (first use in this function) 1341 | return my_syscall4(__NR_wait4, pid, status, options, rusage); If a syscall macro is not supported by a target platform, wrap it with '#ifdef' and 'return -ENOSYS' for the '#else' branch, which lets the other syscalls work as-is and allows developers to fix up the test failures reported by nolibc-test one by one later. This wraps all of the failed syscall macros with '#ifdef' and 'return -ENOSYS' for the '#else' branch, so, all of the undeclared failures are fixed. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/5e7d2adf-e96f-41ca-a4c6-5c87a25d4c9c@app.fastmail.com/ Reviewed-by: Arnd Bergmann Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 78c86f124335..5464f93e863e 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -554,7 +554,11 @@ long getpagesize(void) static __attribute__((unused)) int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { +#ifdef __NR_gettimeofday return my_syscall2(__NR_gettimeofday, tv, tz); +#else + return -ENOSYS; +#endif } static __attribute__((unused)) @@ -672,7 +676,11 @@ int link(const char *old, const char *new) static __attribute__((unused)) off_t sys_lseek(int fd, off_t offset, int whence) { +#ifdef __NR_lseek return my_syscall3(__NR_lseek, fd, offset, whence); +#else + return -ENOSYS; +#endif } static __attribute__((unused)) @@ -1338,7 +1346,11 @@ int unlink(const char *path) static __attribute__((unused)) pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) { +#ifdef __NR_wait4 return my_syscall4(__NR_wait4, pid, status, options, rusage); +#else + return -ENOSYS; +#endif } static __attribute__((unused)) From patchwork Mon Jun 19 12:27:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 109970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2980230vqr; Mon, 19 Jun 2023 05:42:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zriY78WjgRCqyKM4sreEROYVR8mF1vxWZbfbtzEHcOct2zHKpLU3g4kZEEKIJRT+nzRbr X-Received: by 2002:a17:903:2343:b0:1b5:640a:887a with SMTP id c3-20020a170903234300b001b5640a887amr4146214plh.60.1687178557240; Mon, 19 Jun 2023 05:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687178557; cv=none; d=google.com; s=arc-20160816; b=aLNHS+e9qt2HCfQHEOUNH+VUuQd8p7thb7eT0aIIvKYspdZDoujt8WbwMNBMMzkyGU RPKhHgE9UCL36FoJxrPQ9xZLWnkOL3eCwt8fPA/DzQ2kBuh3aIEMQNU5uRvpgawDbthv WcKhhnhae/17/NBZJYvJ5shYIcP9vPkT+IX1oKf2RkvJjyDhpHFWzH5GgNeaS9JRwXis 2+onV10KTK4fY9/jug6wnwpRpqZ+UwGzvXqtoZJotzyozH4YeDQyDpeX+FuA7EctpZ7J IyNTlAynpDUM3NbaQTP9kI0+xmmGf5NXEnj6VK/6ASskb2QpxC73W8uh1eYrbhSLzEGl ukyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=LPiYQdP38zeV6NeTgInFRV9EzONs3cBT0MzmzPaYFJU=; b=ZNyamqeNw1+umMgald2xkMrnQzJkpUDCudapIqrQWJCyyaZGMpsK0oxQF7XEQkxs2Y B8CyYhWBoymsI7CIAkWyj52VWcwd0I0aVPD+Ls/V9X8/ofvKfHHng4NudEUiAseovZMf +HV4d257TtK6qehFyj0RtVOwGlB1OMMi9HxMbpakS+9XQhpnAsGwqVvrADLFFISoJF52 LXqslHMObOiQtOWgnp54s5g6ThJdmr6WpVWDAjOmR3GWoTHfcoHG+szphqIGyEAKO6xj rtEamQpl/kC4ZlzeMy8XxWVCRrK6KPfMcWziunYAgsD2Um759+T+JjZ/gt+rZdrtpGvv dJlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay6-20020a1709028b8600b001a97e24eb34si19786310plb.201.2023.06.19.05.42.23; Mon, 19 Jun 2023 05:42:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229507AbjFSM1w (ORCPT + 99 others); Mon, 19 Jun 2023 08:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjFSM1u (ORCPT ); Mon, 19 Jun 2023 08:27:50 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31E42E65; Mon, 19 Jun 2023 05:27:21 -0700 (PDT) X-QQ-mid: bizesmtp66t1687177631teie4acy Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 19 Jun 2023 20:27:10 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: FVl8EHhfVR4G8njjimH22Yic6dkZ/h69DI80pcJOhgqYGvZ/p2pAaliIhKcCV E2+RX78p2BQadDdb1HY3kl9GzWyCiyTmwr4LHv+OGA+S9WNC/ll+g68ESp594/X4kMaOphE vh2WS3CuISBsyl3Zz8fGxxQiLLuoLKlSt3i1DJBxrhCqNFbafjCsK6PiFPlBhiVnO9zrTPp DlMsNAixfnzM4wnTPRdMU6LO1myVXaj+DDdtE8KSdsUz6rj7JsIww6pmS9w0DjbVzGUVl6x j0Mu6TJlhXjREv5DVU2tF5ejBOyvD+jjmeyLM9yjpUbPyP4VlLiP+tJPQwZ7dEzhYI7ng/4 zAQBbLmoodaPmW2bY7PuhOtE17nv67t3cNSXEPjaZPp+bYdRNCYfbInGOOuiaTx6rlcgFDz X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9699929361938748553 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v5 3/5] selftests/nolibc: allow customize kernel specific ARCH variable Date: Mon, 19 Jun 2023 20:27:06 +0800 Message-Id: <0deeb36e44db5abb936a99d855b86a3c76d2a102.1687176996.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769134942980007218?= X-GMAIL-MSGID: =?utf-8?q?1769134942980007218?= Some architectures (e.g. riscv, mips) share the same ARCH variable (the one supported by top-level kernel Makefile) between 32bit and 64bit architecture variants and even more, some of them have little endian and big endian variants. Let's add KARCH to allow architectures customize their own kernel specific ARCH variable, so, ARCH=$(KARCH) is required by all of the top-level kernel Makefile targets. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/ZIAywHvr6UB1J4of@1wt.eu/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 000621f21adc..ebecb8cfd947 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -14,6 +14,9 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +# kernel supported ARCH names by architecture +KARCH = $(or $(KARCH_$(ARCH)),$(ARCH)) + # kernel image names by architecture IMAGE_i386 = arch/x86/boot/bzImage IMAGE_x86_64 = arch/x86/boot/bzImage @@ -143,10 +146,10 @@ initramfs: nolibc-test $(Q)cp nolibc-test initramfs/init defconfig: - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare + $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare kernel: initramfs - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs + $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs # run the tests after building the kernel run: kernel From patchwork Mon Jun 19 12:28:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 109971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2980274vqr; Mon, 19 Jun 2023 05:42:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lO5mZOTcBvjaDHrupUmIVwZlkGU7/+qCOrllUd7oOh/ThGiqLldYo7BkVtmHaMZOX6XkV X-Received: by 2002:a05:6870:284:b0:17a:ce6b:720 with SMTP id q4-20020a056870028400b0017ace6b0720mr5563169oaf.19.1687178561860; Mon, 19 Jun 2023 05:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687178561; cv=none; d=google.com; s=arc-20160816; b=oJSdn+ZwIt3Tq4GsaE9MXL535XV9qgGWSpqUYtYLQ87crjD9e4RplevFutQWPWOQLm djM5G/v3Kz69Ua3FGPSp9gw5274tRfJhfL/GPCqYNM6dCMXzWnv7mPooaAsTN3iHH6Lm sQYr0GNPbGKLrwz/S5N9ahKU58bo++4O4u37pJhv8rc/AoOLbjJRI4DuFw+DnZPNEgca 41FKpVGIFREEDedqKxqiHrs4z+PaSyaFo10Wjii1YJYEMBvH79MAsQnYUzd6F8qCyVsP HILbY/yCEjNdCUThgbvCa2o/3FCBlJcIiyd/ahEWEPBFay4vXGo6fa9/ICBW6QWmAinn myHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=rYDGHVF5alPHzPKXBM4jQmq6CyeOs31FZ9H8rpgVChs=; b=fDTqK8P+eGdB0iuuWkF9GZ9Kza2FNV6PQnT+4vQ5emOGv88hfE3/F0LZmhd4ky/Mnv d0Ql/3SeSD1EwqZc95zbvCi4JmALNHINuDGo7rB/IJSiatKmIXgv8LZCzx7Jh3jQG+dF P/APIcJpInxPFsTtGfY/q/9QlZ9tdnirG3CG2fW2PYId9QHDMe/yJbivi2AHl1a4diJa ZNiB31x7a0Y/f3RExw99H4H/LUopaq5DOsB9/ozTAUeQjdP4vYKveUhQLfW0zGd9vDyh tCVSOFqvmA2/Wn1r4M6/wNhxynthYb1WQu3yXwzGs7VMNfcPpS87G5id2Fs+i6cp7m9C brlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t75-20020a63784e000000b005250385bfdbsi21038806pgc.549.2023.06.19.05.42.29; Mon, 19 Jun 2023 05:42:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbjFSM2k (ORCPT + 99 others); Mon, 19 Jun 2023 08:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjFSM2j (ORCPT ); Mon, 19 Jun 2023 08:28:39 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9648194; Mon, 19 Jun 2023 05:28:37 -0700 (PDT) X-QQ-mid: bizesmtp81t1687177707tmneyvcl Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 19 Jun 2023 20:28:26 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 5q30pvLz2ic279cw/a00XjnqZBNnxTgxLNGC6G7VMExOCnBfI7C0htyxxzWKY LA5v3ik8/oYs8zCaHGKjtZ/1V4+e1Iwh4i0Rpn+oiq9SYoh6jr/S99wvl/1vEr8p0R4z3ms lgaKQkeqhhNBuB42rTLW0FAGdmmwyykpGkXnchmNDkOAZZ2ilQ+0MpMlTmlCIa9kQYeOtlY BEZOrE68ogo7OmquvaAJweTQn7BQflcMhTRoZ62o4IY59iZqqBLjqz9z2aUByaD/FfITuvj 6WkOZamXc1txAV3HCZJMNwX/kUVydRmuN1Ep+b7mcNTrFyElbsr7yRiHP3vb4XQ/d423peo hKWy5deLwn5KsqDutzogRy0HI4veS/4vusbw+UVoxz58OxqseAmqa5ffwrsFA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4499761798430525214 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v5 4/5] tools/nolibc: add kernel and nolibc specific ARCH variables Date: Mon, 19 Jun 2023 20:28:23 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769134947460518733?= X-GMAIL-MSGID: =?utf-8?q?1769134947460518733?= Like the KARCH added for tools/testing/selftests/nolibc/Makefile, adds KARCH for tools/include/nolibc/Makefile too, at the same time, adds NARCH for the ARCH supported by nolibc (arch-.h). It allows users to customize both kernel and nolibc specific ARCH variables for different architectures and their variants easily. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 64d67b080744..14a6416fa57f 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -23,8 +23,14 @@ else Q=@ endif -nolibc_arch := $(patsubst arm64,aarch64,$(ARCH)) -arch_file := arch-$(nolibc_arch).h +# kernel supported ARCH names by architecture +KARCH = $(or $(KARCH_$(ARCH)),$(ARCH)) + +# nolibc supported ARCH names by architecture +NARCH_arm64 = aarch64 +NARCH = $(or $(NARCH_$(ARCH)),$(ARCH)) + +arch_file := arch-$(NARCH).h all_files := \ compiler.h \ ctype.h \ @@ -83,8 +89,8 @@ headers: fi > $(OUTPUT)sysroot/include/arch.h headers_standalone: headers - $(Q)$(MAKE) -C $(srctree) headers - $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot + $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) headers + $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot clean: $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot" From patchwork Mon Jun 19 12:29:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 109979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2983625vqr; Mon, 19 Jun 2023 05:49:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66FwO5D3vC35r600vQtEhbe+bvhcnA++7BKGVVkKS4tukD/e+jHTSmYvJ2otPyaK+FAbLl X-Received: by 2002:a05:6808:1a08:b0:39a:bd3b:9cb3 with SMTP id bk8-20020a0568081a0800b0039abd3b9cb3mr12943808oib.23.1687178953706; Mon, 19 Jun 2023 05:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687178953; cv=none; d=google.com; s=arc-20160816; b=mQzkrv6EkeLl+GQE9Zur9MjT32kJ7jTLOk691jH4jLDiCRGozZ+rtrrB0G5qKvZWTO J13fY2M/M7r5vBz/YhnoxKjCCDmg8yZnZzYdXhSOd4jkUY1a4ZA1wxkjD6Q2aBZ6YLEa ks1l+TgrrQT9ZeSrXkZi06Cl4ZuXoz0I23TVtYL+CbTG6/IqA//qDqyngda5td4e3WiF n2erzKVL2wmsucVMpSkg8NaPWb/Vlm74qEF0JN6nvShuBNu1qQ2LZCoVtCcbcdFJFxdb RHuGxTl4htnonvCCMH0KXcI82cf1KHzMoKJycHQLKWk+1XvBKEigodbmzsdp/saypEzv IAVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=FR7CyQw+hJxp6t5gmvVd0uVSKcN0vh+omGEIzHMFNro=; b=wXKnpM0HHXLBIODdOHG/TkZUqSR1LlhkmAp79VqtuVh4ZfGCFAbbYtLl4A6QADOYUU 57wQ3o0WY8F0wwXE7QoUl1ZPloSVjzy8gRQcaveGkX35xFFtJMGTcgDGGylz5rDC+tmT 3JjM1sWH+2LxQfPmeIWzfdgch6oOIfB7CMJ7jsboB0xQ+dmGWs09CcMtjjvGG3+dXAfY M6QNSldtvUB79L9t1G2FqNmtHFkyWxZrjALBkZigoa5+9V05kMP2YNzFfxi3PzhwrvZ6 m82q/u0on/YfJrFQ/AedLneBkk8n5QxaQsuZA4rAZTyTg6GR8xvQch4vx+QnQiTy95Iy Lvlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r91-20020a17090a43e400b0025645cd3909si7333036pjg.161.2023.06.19.05.48.58; Mon, 19 Jun 2023 05:49:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjFSMaJ (ORCPT + 99 others); Mon, 19 Jun 2023 08:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjFSM36 (ORCPT ); Mon, 19 Jun 2023 08:29:58 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC0791; Mon, 19 Jun 2023 05:29:55 -0700 (PDT) X-QQ-mid: bizesmtp73t1687177786tu58ycog Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 19 Jun 2023 20:29:45 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: FVl8EHhfVR6mCyZUawKuNgOeziftOVI0KH5LBW2YGVs3vsD+ECpNHgIeXFx/q 55cBDOd3xctgZvSpVrgb9ncBLZmJvIhXd0bvaDoGUnDSGwfJwgKXoZBOkt6tveDZZtIBOYe yuUlrH/9m695KsRymGnpX9XEsCpjLYr58ubytYfvtvKx97yA35zYpfrtNc3svfC6JQ2JpMw hcDSSJ+eskWbHKlMVocljtJZKEb6zGLyGABTNMRap3dnet7EGZJthiLydfUncjWsxNi7xSJ 3BVwRqCjrRMXAhmcehIoXbGhc3LkE9qI3Wfy54GOnDfaNFoXeepNrZpDk+5AiyVj3e0ZZnR IJYKyS445erEkiQ1yfg/CulKRr82dBR/SqneBCvfF/u8j0LPDsJzx2dCCknULy9rL0MqK26 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17039376255074177118 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v5 5/5] selftests/nolibc: riscv: customize makefile for rv32 Date: Mon, 19 Jun 2023 20:29:38 +0800 Message-Id: <2ebfb48c66b18a5fd7d0bd6b7c832a5d8ce6486f.1687176996.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769135358100232664?= X-GMAIL-MSGID: =?utf-8?q?1769135358100232664?= Both riscv64 and riscv32 have: * the same arch/riscv source code tree * the same tools/include/nolibc/arch-riscv.h * the same ARCH=riscv value passed to top-level kernel Makefile The only differences are: * riscv64 uses defconfig, riscv32 uses rv32_defconfig * riscv64 uses qemu-system-riscv64, riscv32 uses qemu-system-riscv32 * riscv32 has different compiler options (-march= and -mabi=) So, riscv32 can share most of the settings with riscv64, add riscv32 support like the original ARCH=riscv support. To align with x86, the default riscv is reserved for riscv64 and a new riscv64 is also added to allow users pass ARCH=riscv64 directly. Since top-level kernel Makefile only accept ARCH=riscv, to make kernel happy, let's set kernel specific KARCH as riscv for both riscv32 and riscv64. And since they share the same arch-riscv.h, let's set nolibc specific NARCH as riscv too. Usage: $ make defconfig ARCH=riscv32 CROSS_COMPILE=riscv64-linux-gnu- ... $ make run ARCH=riscv32 CROSS_COMPILE=riscv64-linux-gnu- ... Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/4a3b1cdf-91d5-4668-925e-21f8f5c64a92@t-8ch.de/ Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/d1c83340-af4c-4780-a101-b9d22b47379c@app.fastmail.com/ Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/ZIAywHvr6UB1J4of@1wt.eu/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/Makefile | 4 ++++ tools/testing/selftests/nolibc/Makefile | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 14a6416fa57f..875e13e3c851 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -24,9 +24,13 @@ Q=@ endif # kernel supported ARCH names by architecture +KARCH_riscv32 = riscv +KARCH_riscv64 = riscv KARCH = $(or $(KARCH_$(ARCH)),$(ARCH)) # nolibc supported ARCH names by architecture +NARCH_riscv32 = riscv +NARCH_riscv64 = riscv NARCH_arm64 = aarch64 NARCH = $(or $(NARCH_$(ARCH)),$(ARCH)) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index ebecb8cfd947..848884204a84 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -15,6 +15,8 @@ ARCH = $(SUBARCH) endif # kernel supported ARCH names by architecture +KARCH_riscv32 = riscv +KARCH_riscv64 = riscv KARCH = $(or $(KARCH_$(ARCH)),$(ARCH)) # kernel image names by architecture @@ -24,6 +26,8 @@ IMAGE_x86 = arch/x86/boot/bzImage IMAGE_arm64 = arch/arm64/boot/Image IMAGE_arm = arch/arm/boot/zImage IMAGE_mips = vmlinuz +IMAGE_riscv32 = arch/riscv/boot/Image +IMAGE_riscv64 = arch/riscv/boot/Image IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi @@ -37,6 +41,8 @@ DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig +DEFCONFIG_riscv32 = rv32_defconfig +DEFCONFIG_riscv64 = defconfig DEFCONFIG_riscv = defconfig DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig @@ -52,6 +58,8 @@ QEMU_ARCH_x86 = x86_64 QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig +QEMU_ARCH_riscv32 = riscv32 +QEMU_ARCH_riscv64 = riscv64 QEMU_ARCH_riscv = riscv64 QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 @@ -64,6 +72,8 @@ QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $( QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_riscv32 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_riscv64 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" @@ -79,6 +89,7 @@ else Q=@ endif +CFLAGS_riscv32 = -march=rv32im -mabi=ilp32 CFLAGS_s390 = -m64 CFLAGS_mips = -EL CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))