From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 66E1C3858018 for ; Tue, 20 Sep 2022 22:02:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 66E1C3858018 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-x62b.google.com with SMTP id c24so3787755plo.3 for ; Tue, 20 Sep 2022 15:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=hs429hcvqncvhtk8XRr6KHT6AanI+ZzUoQei4RACgz0=; b=sTyNHBo80evWiGzLO+xkwS4KszBDNQhLeJh9kiN86LC3cJRtbSDopnNHW/5Li2Vhas WNyk12ASBpXQ6v2Ltt7uhoUgUPA5H+SQXYUeU6XZshm7MrX/pcJVu7pEDHLE8249zfnV Q7g8YVmjArHENKyeFsoXGEholWt7bGCamgfwQgtjx7RTUHRoVp9RnRiK7kiZ5+7yq3NO T6DDkc2RomNES0P+R9fVvooB9/n+i9XzrvHz60KTgW4pAd0SswF/yLJCb/BvMNxDEhyf wIP0yKfwevmp86yNKH3DcXWW8WoNPn7z3ZOCdIgXiVgRIdVrJPdHWSrSAYwcvUqPXgFW OS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=hs429hcvqncvhtk8XRr6KHT6AanI+ZzUoQei4RACgz0=; b=CfcUWUYI87I4qLFwJ5x0RDmdUXX+Gi/RWYOHNQ6CYP8PjbPlnnX/nGcGMTHi3s/ZDc SUdhXICo7cksHtof3SJikQvK/K4mfqJzFAAjqPjtXwXOp6p2Y1kOjTVJLF7KBQPiF0xv RqP5JhC9IwJdULCMyhQwtZABI1KZ5AZOqZCe8Aj+wmw28WaECWJUo4CJ1pboIWN1PlnE CecA4sSiI1o/3JPxRYxdkAoE/BZVFtBTEamKnlqMdjIx3RPUL/5+t79Vvqul7WEog8Re IWfPj35QomWvTNvMHRp/h9ykJ6GrSu2W/lJdoPptPV3+/YCdthVp31UP6bpYxb9uDNxv AKkA== X-Gm-Message-State: ACrzQf1hwjv34a65wmPGT0E9X43aTYiL9tEzcE88UIbzKGE7MI7b1mkj qg6LiuuzG4sl/0uWES+k9YTCQnlbBKHpOQ== X-Google-Smtp-Source: AMsMyM7464Pxz64O5UKRkWHW+24gb7d6PNCIwRaosIfQJuI9kQueZ4R6juXLQrSBaLIEgMyDFAnmgw== X-Received: by 2002:a17:902:720b:b0:178:83e9:11ec with SMTP id ba11-20020a170902720b00b0017883e911ecmr1631060plb.34.1663711358249; Tue, 20 Sep 2022 15:02:38 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:d84:2541:70:6d52]) by smtp.gmail.com with ESMTPSA id h24-20020aa796d8000000b0052d432b4cc0sm430134pfq.33.2022.09.20.15.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 15:02:36 -0700 (PDT) Date: Tue, 20 Sep 2022 15:02:33 -0700 From: Fangrui Song To: Wilco Dijkstra Cc: Florian Weimer , "H.J. Lu" , Wilco Dijkstra via Libc-alpha Subject: Re: [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default Message-ID: <20220920220233.wmj5dossqk2k6dbj@google.com> References: <87pmgj2o1d.fsf@oldenburg.str.redhat.com> <20220829195703.tvrqhe7ggnaks3oo@google.com> <20220915214513.s6uzsy2zvcnevolx@google.com> <87a66um8wz.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,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 server2.sourceware.org List-Id: On 2022-09-20, Wilco Dijkstra wrote: >Hi Florian, > >>> Well if changing the default of fPIC is unacceptable in GCC, adding a >>> new option should help LLVM too since it could imply more than >>> -fno-semantic-interposition.  A key question is whether we could >>> require that exported symbols are marked explicitly so that we only >>> emit GOT and PLT indirections on such exported symbols. >> >> -flto with a linker plugin already covers this.  I don't think we need >> anything else.  Maybe an LTO mode that only deals with visibility, but >> otherwise does little cross-TU optimization? clang -flto={full,thin} respect -fsemantic-interposition. If -fsemantic-interposition is specified, it disables interprocedural optimizations (including inlining) for default visibility non-vague external linkage functions. ( -Ofast unfortunately implies -ffast-math and does crtfastmath.o. ) Piggybacking -fno-semantic-interposition on -Ofast >Well it would be great if LTO solved this problem, but unfortunately it can't... >LTO tells you which symbols are locally defined, but this doesn't help PIC. >Local definitions with default visibility must still indirect via the GOT/PLT, >similarly interprocedural optimizations are still blocked. > >A LTO-lite option that just deals with visibility and global variable optimization >(eg. better use of anchors) and other cheap optimizations seems useful indeed. > >Cheers, >Wilco -fno-semantic-interposition should be sufficient. I think we don't need another option. We should just the few software to use -fsemantic-interposition so that the world can be changed. FreeBSD and quite a few musl-based Linux distributions use Clang as the system compiler and have verified that -fno-semantic-interposition-like default (allow interprocedural optimizations for default visibility non-vague external linkage functions. I think folks can give https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937 another request. Even if the upstream doesn't take it, changing a distro's own spec file to default to -fno-semantic-interposition isn't that difficult. Many Linux distributions customize their GCC to do some stuff by default anyway.