From patchwork Thu Aug 22 21:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1975770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=iXTkX/yK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wqbdj2tQyz1yNm for ; Fri, 23 Aug 2024 07:18:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2266B3861009 for ; Thu, 22 Aug 2024 21:17:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id D97183858430 for ; Thu, 22 Aug 2024 21:17:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D97183858430 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D97183858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724361460; cv=none; b=AR8jGfqRwsrXVAYXMU1cMYex1Q7bfEjJwLQboDRvvLjqa9uIPR+JG7vCkv2Gwf6YXaEI4AdEWQ1BWEdnrBFsuf+zL8dEST+hSP5gHR6jh8JqDfBPhXyg/EQHe76iQcDmSUBHau7ZL863TpeGX+ga9k60seMxhy2aZ3TAa9XbfcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724361460; c=relaxed/simple; bh=U9IaAYhhPQG7hK70eWvT5zVdr1cxsClKvLoR+Ag0kII=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FWUqJwRsmGaEICiQcp4El66/QCIfnFb0f3kEQDOIKA+xueBQQEtGOfyCP4AQQ55uwB/1IV2Km1A85bzzTfqSZu3jpcw5Lo6syFBlLCVoioxe/zY2vjqxotx7wSRXxWDEQEF3C7HO4eWbnvEfOOVYO6bC/WAJ90ID+kIndc/kJa4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MA5xvK030909 for ; Thu, 22 Aug 2024 21:17:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=lbxA0UckvrIk48ynrOPbJ5 IWrHI8VN6EQub/WMuODWo=; b=iXTkX/yK96Acumfo0Sl4BsFZiCyQXyP5bc2/Dc VpHKVo38bTfiGKedAw28zYoi/BodWR+ZNR2uRqwzswkcZoHigEj0SE+yPRh56Gq9 1HKciCfWY0etzGozlZgNwHRTLfe0rwtmkPgzu6zwVPOTEKWN4Bon9hAk8B0kS5YF nM6cdHy8sDuUY+LfPKS8v04nrtLGxMQs06Qjd8WRvbugCzD3QCeG0Rsl0KbEsC0h IfL6G8m9jHA1Cg3zmgJLCpPEwc4+cthQ5F6xY9xPU26ylO98P2WCWiGzKOx+hbRS CwJcbaePMYOMWEE4jWT++i4RZoWfoFFi7ZiJcpg7kuRK05cg== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 415ck9dk0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Aug 2024 21:17:37 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47MLHaoG014381 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Aug 2024 21:17:36 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 22 Aug 2024 14:17:36 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] Don't remove /usr/lib and /lib from when passing to the linker [PR97304/104707] Date: Thu, 22 Aug 2024 14:17:26 -0700 Message-ID: <20240822211726.513334-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: yLTtpZkzWs90XEYXBDhctmk6XDfBmBoi X-Proofpoint-ORIG-GUID: yLTtpZkzWs90XEYXBDhctmk6XDfBmBoi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_15,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=790 suspectscore=0 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408220159 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org With newer ld, the default search library path does not include /usr/lib nor /lib but the driver decides to not pass -L down to the link for these and then in some/most cases libc is not found. This code dates from at least 1992 and it is done in a way which is not safe and does not make sense. So let's remove it. Bootstrapped and tested on x86_64-linux-gnu (which defaults to being a multilib). gcc/ChangeLog: PR driver/104707 PR driver/97304 * gcc.cc (is_directory): Don't not include /usr/lib and /lib for library directory pathes. Remove library argument. (add_to_obstack): Update call to is_directory. (driver_handle_option): Likewise. (spec_path): Likewise. Signed-off-by: Andrew Pinski --- gcc/gcc.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/gcc/gcc.cc b/gcc/gcc.cc index abdb40bfe6e..a02af80ec6e 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -408,7 +408,7 @@ static int do_spec_2 (const char *, const char *); static void do_option_spec (const char *, const char *); static void do_self_spec (const char *); static const char *find_file (const char *); -static int is_directory (const char *, bool); +static int is_directory (const char *); static const char *validate_switches (const char *, bool, bool); static void validate_all_switches (void); static inline void validate_switches_from_spec (const char *, bool); @@ -2940,7 +2940,7 @@ add_to_obstack (char *path, void *data) { struct add_to_obstack_info *info = (struct add_to_obstack_info *) data; - if (info->check_dir && !is_directory (path, false)) + if (info->check_dir && !is_directory (path)) return NULL; if (!info->first_time) @@ -4576,7 +4576,7 @@ driver_handle_option (struct gcc_options *opts, if appending a directory separator actually makes a valid directory name. */ if (!IS_DIR_SEPARATOR (arg[len - 1]) - && is_directory (arg, false)) + && is_directory (arg)) { char *tmp = XNEWVEC (char, len + 2); strcpy (tmp, arg); @@ -6019,7 +6019,7 @@ spec_path (char *path, void *data) memcpy (path + len, info->append, info->append_len + 1); } - if (!is_directory (path, true)) + if (!is_directory (path)) return NULL; do_spec_1 (info->option, 1, NULL); @@ -8041,11 +8041,10 @@ find_file (const char *name) return newname ? newname : name; } -/* Determine whether a directory exists. If LINKER, return 0 for - certain fixed names not needed by the linker. */ +/* Determine whether a directory exists. */ static int -is_directory (const char *path1, bool linker) +is_directory (const char *path1) { int len1; char *path; @@ -8063,17 +8062,6 @@ is_directory (const char *path1, bool linker) *cp++ = '.'; *cp = '\0'; - /* Exclude directories that the linker is known to search. */ - if (linker - && IS_DIR_SEPARATOR (path[0]) - && ((cp - path == 6 - && filename_ncmp (path + 1, "lib", 3) == 0) - || (cp - path == 10 - && filename_ncmp (path + 1, "usr", 3) == 0 - && IS_DIR_SEPARATOR (path[4]) - && filename_ncmp (path + 5, "lib", 3) == 0))) - return 0; - return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode)); }