Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp186899imm; Thu, 12 Jul 2018 17:02:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeGw2aZQ7AkVG3jm6o1kuS/Uq2aJ3x67XiumqxjEeIdRtbK4nheoh57bmmWtBmKm7zgTKaW X-Received: by 2002:a62:1c16:: with SMTP id c22-v6mr4545711pfc.148.1531440136551; Thu, 12 Jul 2018 17:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531440136; cv=none; d=google.com; s=arc-20160816; b=n7W02PimAooNORGvmRgImHInP1vFxfh1hQnq2YBDdUu/10uhSNutMpbf7z6Mvrc/NK ZDyO1GSsRVuRJIFlTujP3Pq1YEB6qupeebS7lef8goo8b/8KoDCBWC3oZyVHsus5cUS7 JW0oGp+75egYd918T/9Xl6wFwpZYGK0j4/kKB084MAdAKeYIxaRrtAY1SpbKofjK9mb2 pxV4TpH0FX85rsJkGwcUyeiEL27jexOCN6L89Gr25VLmeyfY475iOxZ/rvJRNnfYmaDj krVGn/nGQykIwqzqQyuJp6FiMFHbGwwHgzfJot/7Ihhvi4Q2AO+Ox3Ig6JtR4JocsIU1 YWFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=floiBXgg12C4kqU5VTrJdbAukqagbECpPMk7AGzr8YI=; b=lY8Sco8yzGj/Ndv35KWE6+i2NGf9fwmRNIIC2twug2cpXNzt68YvEtNAJJ8nh7ucyY 0k83mRJ4rHpY54hBePZb3f2IFSFzdZzyXmdKid1hPGTEFELA9xW9OYMaF8e4D0dZKUlp Mq7jsZ4qclmdFKxKW9TVMH+nRSu9h/hiw4FXMcV9BzXjak15eaNF0KfpdOQyN1eZZaeM MUq9c1jdggqTeQ1eUDgzMHNnTUhnuh9zpX/d93Af1dlt1wgrymgVd5QXofH+bUwhnjZt TvgO/Dudw1GptmdXCSD08v1G8zFJW9A+D7K1ZiQsDdIikgH2PtFpCltUjgKpGP/Lx3lT a1ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=R32XDzNs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si20427765pgq.457.2018.07.12.17.02.01; Thu, 12 Jul 2018 17:02:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=R32XDzNs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2387772AbeGMANO (ORCPT + 99 others); Thu, 12 Jul 2018 20:13:14 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53411 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387719AbeGMANO (ORCPT ); Thu, 12 Jul 2018 20:13:14 -0400 Received: by mail-it0-f66.google.com with SMTP id a195-v6so9276570itd.3 for ; Thu, 12 Jul 2018 17:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=floiBXgg12C4kqU5VTrJdbAukqagbECpPMk7AGzr8YI=; b=R32XDzNs0gxEj/n+dRwJjUr1NutBy6Ihxn3V7WXAB9o7cp2dYtrCWD3GBR24rUlIfq yLqg7VLeHgyGdc2FFyd8LHQt248NLGYGnif9c6rMB8452MLMLv01Qawvi+PKna9nhY/8 XCiUssIQZJl6AW0hZs82TThTPHz//WObZpt+UK9clgck9ilSnlokjtyozdL31LTQDf/h vAu2psHRXNz54SIVTEK0NUeLhb41yHHsjmuIP36DpGjWRqwmBjs62rPWCSPekKvmJdRf YvwNlUCa48CoqwPVeubkSrQSQjovTHPobMQhfbPgHDC3miDZJTFcTg8+p4Z2MaznTu9s ZudQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=floiBXgg12C4kqU5VTrJdbAukqagbECpPMk7AGzr8YI=; b=Fj2T8Z3YgY3b3Nhle7abPbe9W77e2b9NfpRk7XB+Lnp+4m3hEOE8iEJTt5MPSRZ0XT +jt8OyD66tBM88isuF4rQXpAv+sfHlcfO1nIq2TFAJaEeO5GJPj2LA6WMYlhifkxXykp c/YyTV10qoVjNv1a1tSInY9GJwfIOZ+h0E8j3FZty/0REcW9ONAtltCpE31J0Fo19lFB m2AzTk2m0UD+sx3wnpz4579/irtT1v7zTX9LPzDJgppokjvZK9TKgVV+aOjer83TDteG rMOeO0cUznQld5/le5oK9/aZKhhc5JAwCJVgEmA4Ze3HLWlLawNUOkyFcYveSfCLgz8L qyjQ== X-Gm-Message-State: AOUpUlEYS7t2i6JdUiEeyRtKJBmT87lh64sd55T4FaR4T1bXJ4C66E+1 9AXD4FkTtxuVuQvJ7B77YShbuR9c15aYhS7/gPnEv4C4 X-Received: by 2002:a24:7a84:: with SMTP id a126-v6mr3021211itc.111.1531440078163; Thu, 12 Jul 2018 17:01:18 -0700 (PDT) MIME-Version: 1.0 References: <20180712201032.156997-1-astrachan@google.com> <47d4b24e-8c60-fb3b-3377-62d20c5f3dd1@zytor.com> <1432bfde-41b4-e8aa-037b-fca41a149cb8@zytor.com> <5AB78E47-BC62-4DA5-920B-00E9731AAE04@amacapital.net> In-Reply-To: <5AB78E47-BC62-4DA5-920B-00E9731AAE04@amacapital.net> From: Alistair Strachan Date: Thu, 12 Jul 2018 17:01:06 -0700 Message-ID: Subject: Re: [PATCH] x86: vdso: Fix leaky vdso link with CC=clang To: luto@amacapital.net Cc: hpa@zytor.com, linux-kernel@vger.kernel.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, Greg Kroah-Hartman , x86@kernel.org, kernel-team@android.com, joel@joelfernandes.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 12, 2018 at 4:20 PM Andy Lutomirski wrote: > > > On Jul 12, 2018, at 3:06 PM, H. Peter Anvin wrote: > > > >> On 07/12/18 13:37, Alistair Strachan wrote: > >>> On Thu, Jul 12, 2018 at 1:25 PM H. Peter Anvin wrote: > >>>> On 07/12/18 13:10, Alistair Strachan wrote: > >>>> The vdso{32,64}.so can fail to link with CC=clang when clang tries to > >>>> find a suitable GCC toolchain to link these libraries with. > >>>> > >>>> /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: > >>>> access beyond end of merged section (782) > >>>> > >>>> This happens because the host environment leaked into the cross > >>>> compiler environment due to the way clang searches for suitable GCC > >>>> toolchains. > >>>> > >>> > >>> Is this another clang bug that you want a workaround for in the kernel? > >> > >> Clang is a retargetable compiler (specified with --target=) > >> and so it has a mechanism for searching for suitable binutils (from > >> another "GCC toolchain") to perform assembly and linkage. This > >> mechanism relies on both --target and --gcc-toolchain when > >> cross-compiling, otherwise it will fall back to searching /usr. > >> > >> The --target and --gcc-toolchain flags are already specified correctly > >> in the top level Makefile, but the vdso Makefile rolls its own linker > >> flags and doesn't use KBUILD_CFLAGS. Therefore, these flags get > >> incorrectly dropped from the vdso $CC link command line, and an > >> inconsistency is created between the "GCC toolchain" used to generate > >> the objects for the vdso, and the linker used to link them. > >> > > > > It sounds like there needs to be a more fundamental symbol than > > KBUILD_CFLAGS to contain these kinds of things. > > How about $(CC)? I'm guessing, but I think this wasn't done originally because CC is something the user might reasonably specify on the command line (the other bit comes from CROSS_COMPILE), so doing this via CC would require us to override the CC passed in on the command line. Not sure how to do that, since the vdso makefile is executed with a submake, so the usual "override CC := $(CC) something else" followed by "export CC" doesn't work.