Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3001456rwd; Wed, 14 Jun 2023 09:53:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4F0DJhGXex7TqjAOF3+EJraM+aYvwg3UWwfg+q6A1ur4yp4j7nPdanC5qqhnhiDGJGhEs3 X-Received: by 2002:a92:2a09:0:b0:340:9132:f99 with SMTP id r9-20020a922a09000000b0034091320f99mr2890985ile.22.1686761608734; Wed, 14 Jun 2023 09:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686761608; cv=none; d=google.com; s=arc-20160816; b=mPv/c/sVzzDtl4zfq1emEPSiDfVdymmGhG3S7TC5tePlxQP8tfxM0w+DZzNXgSfMrC 2mgYiFTRgNqB0bQQliKKuWkfggYX+sH0lBjR5mpwzavSHZjE1qWvVERNgnaVTSwaXyXw t5jaTdFf/8BaR75EQwO9jeEXakwZNO7Xc5mN3UvSQflzCE6hQvmu29xvTahMFX9vHRul svzEXsL94q9Q7dchlRiB3CRBogsVxEtFmhqZU4ZmnQZsK8hyM9nJ/rTM1mAxbkPxpqEH Ep3JexhfEoAvDd///EasziEMzNFv9yoZTTCnPkVApJERZz+Oq9Qh2oHlaZoHlJEDqmeP jKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UXimn/P/5sCJZ7fCJTZ8BSazPdQnTt6zyCupGqR8k5w=; b=tXvOcw96SNzmunHbzfUIqzCR3Y9kxveFaVlzGq3to8WmtKwJILb8l98huKMwN0G9T/ SnPaOIXwoWL9oWFlfpHtJHzgEbSuFPGbYJ6kEIplFf1aAAoc+qpW+SCCVPhEZf2pTZ4J vdf5WSycDyLY2dgpqtJQV9AVYhMlWr8e+cxCMh0xmsvanq2CeKa97vP7Hqh8skwLV6Yx qvCjkMw3XvwCQbRoSI9gvdoTySRcjgwX/S67oGeTkCQWht8um70HhmVEu3nkCzKSrJIT ZAdcfY35t0IrgzxGu+PxbdOguiRcBSGxywfsg6FiRbGlkMw/fO8dsRX6Benm0IiOuUgy llhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OAoITSnt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a63af45000000b00517ab01bb8fsi11118614pgo.100.2023.06.14.09.52.50; Wed, 14 Jun 2023 09:53:28 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=OAoITSnt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235335AbjFNQkz (ORCPT + 99 others); Wed, 14 Jun 2023 12:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236014AbjFNQkm (ORCPT ); Wed, 14 Jun 2023 12:40:42 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D93EEC for ; Wed, 14 Jun 2023 09:40:41 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-75d54faa03eso228338785a.1 for ; Wed, 14 Jun 2023 09:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686760840; x=1689352840; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UXimn/P/5sCJZ7fCJTZ8BSazPdQnTt6zyCupGqR8k5w=; b=OAoITSntNBYS+uJgf1ujmP2eeCLW9WF/FTefuiku8oybwrFBx+upKikf92RbfxXDE+ LnYGDbG150ZKoTMWfmq3xvUFJt8/h0GeDKE4BfhS5mPt4LFm8IFdGz0371yuNV+Z/fKH BFj0AXE1/uumb9GBim7y91GR0ZrJp5EcO87efwp3wOhNFp8ZrMk82cAtVmQFn+3r6q/O Rg1fgvFf/yOlmVFHUa43o0hvV3WXx27jsfTzl4CuRT9dho1R5DLVFyrR9QiIkd9mP4Mt zzG27bxORvKu5rmKLtRzdL3zlEvwsqLHG5zaL7qJcVVUT6AFxL+ONDCwRBish4r8Ujgu EM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686760840; x=1689352840; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UXimn/P/5sCJZ7fCJTZ8BSazPdQnTt6zyCupGqR8k5w=; b=IRWkkkbj8O0QN6eCbOmfhm8aGQKWKcZQ4gk2RlXVJNSR6kT+1gOOvoImahNC1JmMmY C3m8/6uRsxQ02sOtQs0PsdvW3wfKKh3uqN7umBytP/bDA0K4tGyi9PT65ySPyCvv1qxa 22vxlCgfiN0n0UwEsTrPQO11UHyCFmGsmkcExu33hoDYzaTVV0KHp6Q/exnA1ejLO0o8 qMTDtw1DWPc6eP1ELDyj/EKee/uw2cli4AKmT2qkWNEj9AhFaCdLJ3RzqxcEPn9hDlja vcqHTxLyOqB1IRNabp66vjwaEaNOzaV4wvUJAnbJCQppAhWee6l8wG217E+yQ4/Vvhgy T/7w== X-Gm-Message-State: AC+VfDytoTiOqokYZKvCPWaP6fZMOt6a9vEbkfkJsQAgyk0H+m/5qMWV rHaG0P+2sxZBpQKvAZml2PD75NLeDTzungGayFgtOqpbUxGA4t345GU8uA== X-Received: by 2002:a05:6214:e6e:b0:628:6abe:f06e with SMTP id jz14-20020a0562140e6e00b006286abef06emr17513666qvb.41.1686760840396; Wed, 14 Jun 2023 09:40:40 -0700 (PDT) MIME-Version: 1.0 References: <202306110855.7TlBCIzI-lkp@intel.com> In-Reply-To: From: Nick Desaulniers Date: Wed, 14 Jun 2023 12:40:28 -0400 Message-ID: Subject: Re: ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol 'misaligned_access_speed'; recompile with -fPIC To: Alexandre Ghiti Cc: kernel test robot , llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 On Tue, Jun 13, 2023 at 4:17=E2=80=AFAM Alexandre Ghiti wrote: > > On Sun, Jun 11, 2023 at 2:11=E2=80=AFAM kernel test robot = wrote: > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.= git master > > head: 022ce8862dff83c859089cd14bc4dca0733e2f90 > > commit: 8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 riscv: Fix relocatable= kernels with early alternatives using -fno-pie > > date: 10 days ago > > config: riscv-randconfig-r022-20230611 (https://download.01.org/0day-ci= /archive/20230611/202306110855.7TlBCIzI-lkp@intel.com/config) > > compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.gi= t ae42196bc493ffe877a7e3dff8be32035dea4d07) > > reproduce (this is a W=3D1 build): > > mkdir -p ~/bin > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/s= bin/make.cross -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # install riscv cross compiling tool for clang build > > # apt-get install binutils-riscv64-linux-gnu > > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linu= x.git/commit/?id=3D8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 > > git remote add linus https://git.kernel.org/pub/scm/linux/kerne= l/git/torvalds/linux.git > > git fetch --no-tags linus master > > git checkout 8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 > > # save the config file > > mkdir build_dir && cp config build_dir/.config > > COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang ~/bin/make.= cross W=3D1 O=3Dbuild_dir ARCH=3Driscv olddefconfig > > COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang ~/bin/make.= cross W=3D1 O=3Dbuild_dir ARCH=3Driscv SHELL=3D/bin/bash > > > > If you fix the issue in a separate patch/commit (i.e. not just a new ve= rsion of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot > > | Closes: https://lore.kernel.org/oe-kbuild-all/202306110855.7TlBCIzI-l= kp@intel.com/ > > > > All errors (new ones prefixed by >>): > > > > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol= 'misaligned_access_speed'; recompile with -fPIC > > >>> defined in vmlinux.a(arch/riscv/kernel/cpufeature.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_feature_pr= obe_func) in archive vmlinux.a > > -- > > >> ld.lld: error: relocation R_RISCV_LO12_I cannot be used against symb= ol 'misaligned_access_speed'; recompile with -fPIC > > >>> defined in vmlinux.a(arch/riscv/kernel/cpufeature.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_feature_pr= obe_func) in archive vmlinux.a > > -- > > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol= 'riscv_cbom_block_size'; recompile with -fPIC > > >>> defined in vmlinux.a(arch/riscv/mm/cacheflush.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_errata_pat= ch_func) in archive vmlinux.a > > -- > > >> ld.lld: error: relocation R_RISCV_LO12_S cannot be used against symb= ol 'riscv_cbom_block_size'; recompile with -fPIC > > >>> defined in vmlinux.a(arch/riscv/mm/cacheflush.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_errata_pat= ch_func) in archive vmlinux.a > > -- > > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol= '__per_cpu_offset'; recompile with -fPIC > > >>> defined in vmlinux.a(mm/percpu.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_feature_pr= obe_func) in archive vmlinux.a > > -- > > >> ld.lld: error: relocation R_RISCV_LO12_I cannot be used against symb= ol '__per_cpu_offset'; recompile with -fPIC > > >>> defined in vmlinux.a(mm/percpu.o) > > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) > > >>> arch/riscv/errata/thead/errata.o:(thead_feature_pr= obe_func) in archive vmlinux.a > > > > So I looked into those errors, the config is basically =3D RELOCATABLE + > MEDLOW - EARLY_ALTERNATIVES. Then errata/thead is not compiled as Thanks for taking a look. Shouldn't CONFIG_RELOCATABLE be setting -fPIC? If so, why is LLD complaining about -fPIC not being used? arch/riscv/Makefile sets -fPIE if CONFIG_RELOCATABLE =3D=3D y. Is it possible that -fpie was dropped for these object files, or -fno-pic or -fno-pie was added to the cflags for these object files somehow? I've filed https://github.com/ClangBuiltLinux/linux/issues/1872 to track this. > medany, which makes sense since we only need this code to be medany > when EARLY_ALTERNATIVES is enabled (because the code would be executed > with mmu off, which is not the case here). > > I can fix those errors by adding the medany flag, but I'm not sure > actually we want to do that since we do not need it and gcc does not > complain: any idea? > > Alex > > > > > -- > > 0-DAY CI Kernel Test Service > > https://github.com/intel/lkp-tests/wiki > --=20 Thanks, ~Nick Desaulniers