From patchwork Tue Nov 2 19:57:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 46965 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A52DA385801A for ; Tue, 2 Nov 2021 19:59:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A52DA385801A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635883174; bh=pOPUBoncSRzXeltxUdBA7Dh4CddU/iask3aBFSLMvIw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xypVuxuLt7Q6AK1UiHcQIeihBw8P4E80rhXbS3LZAE4Boa532pTAY1AFArHTk6rb2 73NsF68O85Xy4OfHVaJYKvboP7twBFnHKF32XSl2TBEgfQU5BxUt/cW8TEvc8Z1taq z9JtWDRSLI3BEMcu6ikR809uY8/QXqBdOaIRPGR4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 30959385842B for ; Tue, 2 Nov 2021 19:57:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30959385842B Received: by mail-oi1-x232.google.com with SMTP id g125so440263oif.9 for ; Tue, 02 Nov 2021 12:57:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pOPUBoncSRzXeltxUdBA7Dh4CddU/iask3aBFSLMvIw=; b=rGA5tcJiCw1oMiwg6M5aJESdEG+KBlThuTXPFtYhKZw9rf9ROSWzMsVM3de0SZrfNn OtfCUV/NfIwExdPZQ2qDgh1U51pOwYZwWwpupjwTqiZfD6xrHkpVJmImzCoRn8paS0hc 1tTu6PBvEC8KOBDKLCKIeqCxWsn7w4a68IoJd0NU0aAZVL1De5H2+vq65JeInp8ms/b3 X9jDGmVBiI2K+AXKsf9TwQoE4JUX1rKZ33LZL/CzeZtqwoMQOYL+y8MxTlmOvD3KPrAY Zm3DavVmGgmfujmTIUbPFHoa5FDx8DCDcqCPcqLhGkApdGfxlZYiUI/PjmiZUI/t3F54 dvWg== X-Gm-Message-State: AOAM533rE+dMPEsbb1Y9yBxqWg/MwpvPy0sxz+bv2MgAqE3AqxJWKR3H Th8qvlYTOlUV4MwjktaOyikI7meVud4Nww== X-Google-Smtp-Source: ABdhPJwRifv6/8v6VoblSXNgDPHWR++2KIZvVdi88epwMudPEbA5hyw5vaeYXKT3MjJGAqyfL8TOEQ== X-Received: by 2002:a05:6808:e90:: with SMTP id k16mr6803548oil.166.1635883044494; Tue, 02 Nov 2021 12:57:24 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:b64f:2d14:9d31:3214:afc6]) by smtp.gmail.com with ESMTPSA id a80sm424429oob.6.2021.11.02.12.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 12:57:24 -0700 (PDT) To: libc-alpha@sourceware.org, Fangrui Song Subject: [PATCH] riscv: Build with -mno-relax if linker does not support R_RISCV_ALIGN Date: Tue, 2 Nov 2021 16:57:20 -0300 Message-Id: <20211102195720.1979908-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It allows build both glibc and tests with lld (Since lld does not support R_RISCV_ALIGN linker relaxation). Checked with a build for riscv32-linux-gnu-rv32imafdc-ilp32d and riscv64-linux-gnu-rv64imafdc-lp64d. Reviewed-by: H.J. Lu Reviewed-by: Fangrui Song --- sysdeps/riscv/Makefile | 6 ++++++ sysdeps/riscv/configure | 30 ++++++++++++++++++++++++++++++ sysdeps/riscv/configure.ac | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile index 20a9968106..8fb10b164f 100644 --- a/sysdeps/riscv/Makefile +++ b/sysdeps/riscv/Makefile @@ -5,3 +5,9 @@ endif # RISC-V's assembler also needs to know about PIC as it changes the definition # of some assembler macros. ASFLAGS-.os += $(pic-ccflag) + +ifeq (no,$(riscv-r-align)) +ASFLAGS-.os += -Wa,-mno-relax +ASFLAGS-.o += -Wa,-mno-relax +sysdep-CFLAGS += -mno-relax +endif diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure index 53f5f1b5f1..4a56fca94b 100644 --- a/sysdeps/riscv/configure +++ b/sysdeps/riscv/configure @@ -2,3 +2,33 @@ # Local configure fragment for sysdeps/riscv/elf. $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h + + +# Check if static linker supports R_RISCV_ALIGN +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for R_RISCV_ALIGN linker relaxation support" >&5 +$as_echo_n "checking for R_RISCV_ALIGN linker relaxation support... " >&6; } +if ${libc_cv_riscv_r_align+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.S <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_riscv_r_align=yes + fi + rm -rf conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_riscv_r_align" >&5 +$as_echo "$libc_cv_riscv_r_align" >&6; } +config_vars="$config_vars +riscv-r-align = $libc_cv_riscv_r_align" diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac index 34f62d4b4b..44a5279903 100644 --- a/sysdeps/riscv/configure.ac +++ b/sysdeps/riscv/configure.ac @@ -2,3 +2,19 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. # Local configure fragment for sysdeps/riscv/elf. AC_DEFINE(PI_STATIC_AND_HIDDEN) + +# Check if static linker supports R_RISCV_ALIGN +AC_CACHE_CHECK([for R_RISCV_ALIGN linker relaxation support], [libc_cv_riscv_r_align],[dnl + cat > conftest.S <