lkml.org 
[lkml]   [2022]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patches in this message
    /
    SubjectRe: [PATCH v7 0/5] LoongArch: Support toolchain with new relocation types
    From
    Date
    On Thu, 2022-09-01 at 10:17 +0800, Huacai Chen wrote:

    > Now all global variable accesses are via got, I think the performance
    > may be much worse than before when we didn't use explicit-relocs.
    > I don't know whether "a new code model" or your "(1)(2)(3)" is easier
    > to implement, but I think it is better to solve the performance issue
    > before 6.1-rc1.

    Hi Huacai,

    We've added a GCC option for this at https://gcc.gnu.org/r13-2433. On
    the kernel side we need a one-line change:

    diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
    index 92c4a52c4c3e..69b39ba3a09d 100644
    --- a/arch/loongarch/Makefile
    +++ b/arch/loongarch/Makefile
    @@ -54,6 +54,7 @@ LDFLAGS_vmlinux += -G0 -static -n -nostdlib
    # upgrade the compiler or downgrade the assembler.
    ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
    cflags-y += -mexplicit-relocs
    +KBUILD_CFLAGS_KERNEL += -mdirect-extern-access
    else
    cflags-y += $(call cc-option,-mno-explicit-relocs)
    KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
    And we also need a one-line change in the EFI stub patch (under review):

    diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
    index 8931ed24379e..8c1225b92492 100644
    --- a/drivers/firmware/efi/libstub/Makefile
    +++ b/drivers/firmware/efi/libstub/Makefile
    @@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
    cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
    -fpic
    cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
    - -fpic
    + -fpie

    cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt

    (Some explanation: -fpic does not only mean "generate position-
    independent code", but "generate position-independent code *suitable for
    use in a shared library*". On LoongArch -mdirect-extern-access cannot
    work for a shared library so the "-fpic -mdirect-extern-access"
    combination is rejected deliberately.)
    Not sure how to submit these changes properly... Do you prefer me to
    send V8 of this series or a single patch on top of your tree on GitHub?

    --
    Xi Ruoyao <xry111@xry111.site>
    School of Aerospace Science and Technology, Xidian University

    \
     
     \ /
      Last update: 2022-09-06 02:32    [W:3.029 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site