From patchwork Tue Dec 28 13:10:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 49334 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 C50EE3857C47 for ; Tue, 28 Dec 2021 13:10:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 396C33858C60 for ; Tue, 28 Dec 2021 13:10:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 396C33858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E0351210FD; Tue, 28 Dec 2021 13:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1640697006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e7KqBc7Bsubczx/72GGzxj7nfJvQhz3jHxJCHLYkdGA=; b=FAE8el7ogpJ5Lc05CoSnn6utskMv9sPsszOhvhZpJKd3mMuFmfnB7nMKWu6l5LkikWMIPw +pNsoDzHOAZ7JPLrhtkOQA0OGITpHLxailBV21oiBu1B3k5CFnt6nJHBxTiTMmsqluyK7q EhLzJ+wxoGCGvhrxI19R2Hr9jX3g+60= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1640697006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e7KqBc7Bsubczx/72GGzxj7nfJvQhz3jHxJCHLYkdGA=; b=yJhXRZ+KVc+G//AHCnc+toTNTRj2lTWrMU59ifEaDqDYOHZyIVXTk9k7GPtvEezQJEwZm4 0JBR7IFg4EBR+mDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C972E13ADF; Tue, 28 Dec 2021 13:10:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0AShL64My2GHIQAAMHmgww (envelope-from ); Tue, 28 Dec 2021 13:10:06 +0000 Message-ID: <8b943a67-4b1e-9fa1-4422-220d984387ac@suse.cz> Date: Tue, 28 Dec 2021 14:10:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Support ld.mold linker. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rui314@gmail.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hello. The mold linker is getting quite popular and I think we should support it: https://github.com/rui314/mold Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin --- gcc/collect2.c | 10 +++++++--- gcc/common.opt | 4 ++++ gcc/gcc.c | 4 ++++ gcc/opts.c | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/collect2.c b/gcc/collect2.c index d47fe3f9195..b322527847c 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -776,6 +776,7 @@ main (int argc, char **argv) USE_GOLD_LD, USE_BFD_LD, USE_LLD_LD, + USE_MOLD_LD, USE_LD_MAX } selected_linker = USE_DEFAULT_LD; static const char *const ld_suffixes[USE_LD_MAX] = @@ -784,7 +785,8 @@ main (int argc, char **argv) PLUGIN_LD_SUFFIX, "ld.gold", "ld.bfd", - "ld.lld" + "ld.lld", + "ld.mold" }; static const char *const real_ld_suffix = "real-ld"; static const char *const collect_ld_suffix = "collect-ld"; @@ -957,6 +959,8 @@ main (int argc, char **argv) selected_linker = USE_GOLD_LD; else if (strcmp (argv[i], "-fuse-ld=lld") == 0) selected_linker = USE_LLD_LD; + else if (strcmp (argv[i], "-fuse-ld=mold") == 0) + selected_linker = USE_MOLD_LD; else if (startswith (argv[i], "-o")) { /* Parse the output filename if it's given so that we can make @@ -1048,7 +1052,7 @@ main (int argc, char **argv) ld_file_name = 0; #ifdef DEFAULT_LINKER if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD || - selected_linker == USE_LLD_LD) + selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD) { char *linker_name; # ifdef HOST_EXECUTABLE_SUFFIX @@ -1283,7 +1287,7 @@ main (int argc, char **argv) else if (!use_collect_ld && startswith (arg, "-fuse-ld=")) { - /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */ + /* Do not pass -fuse-ld={bfd|gold|lld|mold} to the linker. */ ld1--; ld2--; } diff --git a/gcc/common.opt b/gcc/common.opt index 2ed818d6057..dba3fa886f9 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3046,6 +3046,10 @@ fuse-ld=lld Common Driver Negative(fuse-ld=lld) Use the lld LLVM linker instead of the default linker. +fuse-ld=mold +Common Driver Negative(fuse-ld=mold) +Use the Modern linker (MOLD) linker instead of the default linker. + fuse-linker-plugin Common Undocumented Var(flag_use_linker_plugin) diff --git a/gcc/gcc.c b/gcc/gcc.c index b75b50b87b2..06e18a75b52 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -4282,6 +4282,10 @@ driver_handle_option (struct gcc_options *opts, use_ld = ".gold"; break; + case OPT_fuse_ld_mold: + use_ld = ".mold"; + break; + case OPT_fcompare_debug_second: compare_debug_second = 1; break; diff --git a/gcc/opts.c b/gcc/opts.c index cdd6463e49b..60f1cf045c9 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -3094,6 +3094,7 @@ common_handle_option (struct gcc_options *opts, case OPT_fuse_ld_bfd: case OPT_fuse_ld_gold: case OPT_fuse_ld_lld: + case OPT_fuse_ld_mold: case OPT_fuse_linker_plugin: /* No-op. Used by the driver and passed to us because it starts with f.*/ break;