From patchwork Sat Aug 13 20:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 11359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AAB0C19F2D for ; Sat, 13 Aug 2022 20:35:06 +0000 (UTC) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web09.8722.1660422904740592503 for ; Sat, 13 Aug 2022 13:35:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=L77tqrJd; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.44, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f44.google.com with SMTP id q30so4648556wra.11 for ; Sat, 13 Aug 2022 13:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc; bh=HH4iRuQ+HK+qfyubj5jcUmwzn4FBH7IHI+7FcrmdOdo=; b=L77tqrJdb0JtTWtPN9OA9afD5ozcUUmWJIgjtTzpe0mox8Rkb3Su0m6NgaJWJVi9aD V6+EK1ri2fWVe9LtjaeC0T1OoU+QyKtzn466vMc0KCypPCk8A+AnrROyJ1Tmst/Exrq7 q/qvpNHfj801Ml69HUndORCOFD+KuRkkvawiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=HH4iRuQ+HK+qfyubj5jcUmwzn4FBH7IHI+7FcrmdOdo=; b=ljQRKGg31g8cLuDtUPwBbgiOQzgxNqTHgUOi5LJiG6Y3bbV9zMDBADuDtzYDJH56jL C9GrdU6GQolrZOyLadVBTAEYnX14KqGjNzcpKWC7+yEQEGbVv1cBo6q0XqcCY6d4Q/zR tjih9Bcr4tAys4Pv5SqH+OLLfP3RpfMFZpmj6EoVT04SIcW20f4XFT/32uAVDIxydy1j dRI3THXcMf7pqwLPOXvVRTEGzYfeRCkIFU+ENAnW6pTjhSJTKb8AX8QdEOujs227z48e F8XJ387eZ/t/ul5JW9EvJDc6gnZzaY/YQ2iE+9rDWVf2G93eUPgHCAZdDNexibVPxV5H PwRQ== X-Gm-Message-State: ACgBeo0XUdms1Kc2+tnqa5iBiQV5279C7NG3KE0oRsY479d2Mr+fyCa+ SYoTVD2FO3tiqxCgY8MqNrFtkcr7MNTHiw== X-Google-Smtp-Source: AA6agR6N/uk46DgFkE8c+BJAdhOCmt6X0vb6Xg0XgQK5+rmaXFCC4wdND/OxFzxtobNyMlVHC+Pq4A== X-Received: by 2002:adf:e5ca:0:b0:21f:15f2:9894 with SMTP id a10-20020adfe5ca000000b0021f15f29894mr5223486wrn.115.1660422902471; Sat, 13 Aug 2022 13:35:02 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f6d8:ef31:d475:da8f]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a1980d55c4sm4182050wmq.47.2022.08.13.13.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 13:35:01 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/5] gcc: Resolve relative prefix-map filenames Date: Sat, 13 Aug 2022 21:34:57 +0100 Message-Id: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Aug 2022 20:35:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169313 Add a patch to gcc so that relative paths are handled by -fdebug-prefix-map and friends. In OE we use relative paths in autotools and removing that creates a lot of issues we'd have to fix. This alternative allows us to fix the paths within gcc and improve our debug file coverage (and SPDX manifests) accordingly. Signed-off-by: Richard Purdie --- meta/recipes-devtools/gcc/gcc-12.1.inc | 1 + .../gcc/gcc/prefix-map-realpath.patch | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch diff --git a/meta/recipes-devtools/gcc/gcc-12.1.inc b/meta/recipes-devtools/gcc/gcc-12.1.inc index 56678c78bef..c42fa3d72f0 100644 --- a/meta/recipes-devtools/gcc/gcc-12.1.inc +++ b/meta/recipes-devtools/gcc/gcc-12.1.inc @@ -65,6 +65,7 @@ SRC_URI = "${BASEURI} \ file://0025-Move-sched.h-include-ahead-of-user-headers.patch \ file://0026-rust-recursion-limit.patch \ file://0001-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch \ + file://prefix-map-realpath.patch \ " SRC_URI[sha256sum] = "62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b" diff --git a/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch b/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch new file mode 100644 index 00000000000..137fc645624 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch @@ -0,0 +1,46 @@ +Relative paths don't work with -fdebug-prefix-map and friends. This +can lead to paths which the user wanted to be remapped being missed. +Setting -fdebug-prefix-map to work with a relative path isn't practical +either. + +Instead, call gcc's realpath function on the incomming path name before +comparing it with the remapping. This means other issues like symlinks +are also accounted for and leads to a more consistent remapping experience. + +Upstream-Status: Pending [need to see if gcc developers would accept this] +Signed-off-by: Richard Purdie + + +Index: gcc-12.1.0/gcc/file-prefix-map.cc +=================================================================== +--- gcc-12.1.0.orig/gcc/file-prefix-map.cc ++++ gcc-12.1.0/gcc/file-prefix-map.cc +@@ -70,19 +70,25 @@ remap_filename (file_prefix_map *maps, c + file_prefix_map *map; + char *s; + const char *name; ++ char *realname; + size_t name_len; + ++ realname = lrealpath (filename); ++ + for (map = maps; map; map = map->next) +- if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0) ++ if (filename_ncmp (realname, map->old_prefix, map->old_len) == 0) + break; +- if (!map) ++ if (!map) { ++ free (realname); + return filename; +- name = filename + map->old_len; ++ } ++ name = realname + map->old_len; + name_len = strlen (name) + 1; + + s = (char *) ggc_alloc_atomic (name_len + map->new_len); + memcpy (s, map->new_prefix, map->new_len); + memcpy (s + map->new_len, name, name_len); ++ free (realname); + return s; + } + From patchwork Sat Aug 13 20:34:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 11360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C586C3F6B0 for ; Sat, 13 Aug 2022 20:35:06 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web11.8558.1660422905151526232 for ; Sat, 13 Aug 2022 13:35:05 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=QTPSMbki; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.42, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f42.google.com with SMTP id j7so4678930wrh.3 for ; Sat, 13 Aug 2022 13:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=QBT+jHDdtvtu22KpPbuQ1AGEVdBbC9mwR0GrFr1eTXo=; b=QTPSMbkiXzo+iJYLWGA2eJbe1velRGanG94RtY8A3iUckeAou+sm9KUszLaihTFeIT 0TnBXJUi0ZCEWNwnoBC5FDdL2jhwZYPwpQtdXftlckkeYp1lo+dTah+q07zi+OVv070F qohYnMdKq+ZPlDfCLhYKlGgnIxOtyzBxL+u+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=QBT+jHDdtvtu22KpPbuQ1AGEVdBbC9mwR0GrFr1eTXo=; b=s5E9aeJoyXD2/t9mclpTrYG3JHpLf47hZDDInDzknz8uTH2cOmeMmYepogdv/HcalT fioUtY12A6WMOGRmdDufw9Oa2Xy5lbMPhK/Lb1X+8lTK2AkHst6vc/p8L4i3Sbq04Eko oDliVxd2BSnkWM6P1VTr6P0rFUX6A2BN9+bR67ZtnUxtsfI9x61gJUHH7rmY+8IONBay +jfTHBw/bZavMB+lzXZjPWU9DUaUZZQVLeROaLcb3Z3LlJK7fPWQXzIuc5opqF6xQkXV tl949mcDRayPh3zrqjLuRLTXOmB2nuShY/4ufmoGr2g4ZDlBO0gZKyyR+vy3JMgQh+hR HD1w== X-Gm-Message-State: ACgBeo1jEB9b6kAEkwYyHlLLG4EirbPDbnTWT/8+D+J2rZR7IakceE5G CwipxLx7CcVL/PAsGoVBp6kf/UVm8varyA== X-Google-Smtp-Source: AA6agR7icZdFHSRltDITCWQ9JdpQLeCpR4f7r2IlouhKb+jvJO7TrY1NC19lYNRL1n+PSIPfa+Z32A== X-Received: by 2002:a05:6000:18a2:b0:221:7d32:e6a5 with SMTP id b2-20020a05600018a200b002217d32e6a5mr4998302wri.278.1660422903170; Sat, 13 Aug 2022 13:35:03 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f6d8:ef31:d475:da8f]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a1980d55c4sm4182050wmq.47.2022.08.13.13.35.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 13:35:02 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/5] package: Switch debug source handling to use prefix map Date: Sat, 13 Aug 2022 21:34:58 +0100 Message-Id: <20220813203501.1111519-2-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> References: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Aug 2022 20:35:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169314 Reproducible builds are no longer a configuration option but are required. We also rely on the prefix mapping capability of the compilers now. As such, rewrite the source locating code to use the prefix maps instead of taking a guess about WORKDIR which isn't correct for kernels, gcc, externalsrc and probably more. Instead, iterate the maps to locate any matching source code, keeping in mind that multiple maps may map to one target location. Signed-off-by: Richard Purdie --- meta/classes-global/package.bbclass | 68 ++++++++++++----------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass index 418400da8c9..2d985d8affd 100644 --- a/meta/classes-global/package.bbclass +++ b/meta/classes-global/package.bbclass @@ -565,26 +565,16 @@ def copydebugsources(debugsrcdir, sources, d): objcopy = d.getVar("OBJCOPY") workdir = d.getVar("WORKDIR") sdir = d.getVar("S") - sparentdir = os.path.dirname(os.path.dirname(sdir)) - sbasedir = os.path.basename(os.path.dirname(sdir)) + "/" + os.path.basename(sdir) - workparentdir = os.path.dirname(os.path.dirname(workdir)) - workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir) - - # If S isnt based on WORKDIR we can infer our sources are located elsewhere, - # e.g. using externalsrc; use S as base for our dirs - if workdir in sdir or 'work-shared' in sdir: - basedir = workbasedir - parentdir = workparentdir - else: - basedir = sbasedir - parentdir = sparentdir + cflags = d.expand("${CFLAGS}") - # If build path exists in sourcefile, it means toolchain did not use - # -fdebug-prefix-map to compile - if checkbuildpath(sourcefile, d): - localsrc_prefix = parentdir + "/" - else: - localsrc_prefix = "/usr/src/debug/" + prefixmap = {} + for flag in cflags.split(): + if not flag.startswith("-fdebug-prefix-map"): + continue + if "recipe-sysroot" in flag: + continue + flag = flag.split("=") + prefixmap[flag[1]] = flag[2] nosuchdir = [] basepath = dvar @@ -595,28 +585,26 @@ def copydebugsources(debugsrcdir, sources, d): bb.utils.mkdirhier(basepath) cpath.updatecache(basepath) - # Ignore files from the recipe sysroots (target and native) - processdebugsrc = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((|)$|/.*recipe-sysroot.*/)' | " - # We need to ignore files that are not actually ours - # we do this by only paying attention to items from this package - processdebugsrc += "fgrep -zw '%s' | " - # Remove prefix in the source paths - processdebugsrc += "sed 's#%s##g' | " - processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" - - cmd = processdebugsrc % (sourcefile, basedir, localsrc_prefix, parentdir, dvar, debugsrcdir) - try: - subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) - except subprocess.CalledProcessError: - # Can "fail" if internal headers/transient sources are attempted - pass - - # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. - # Work around this by manually finding and copying any symbolic links that made it through. - cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \ - (dvar, debugsrcdir, dvar, debugsrcdir, parentdir, dvar, debugsrcdir) - subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) + for pmap in prefixmap: + # Ignore files from the recipe sysroots (target and native) + cmd = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((|)$|/.*recipe-sysroot.*/)' | " % sourcefile + # We need to ignore files that are not actually ours + # we do this by only paying attention to items from this package + cmd += "fgrep -zw '%s' | " % prefixmap[pmap] + # Remove prefix in the source paths + cmd += "sed 's#%s/##g' | " % (prefixmap[pmap]) + cmd += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" % (pmap, dvar, prefixmap[pmap]) + try: + subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError: + # Can "fail" if internal headers/transient sources are attempted + pass + # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. + # Work around this by manually finding and copying any symbolic links that made it through. + cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \ + (dvar, prefixmap[pmap], dvar, prefixmap[pmap], pmap, dvar, prefixmap[pmap]) + subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) # debugsources.list may be polluted from the host if we used externalsrc, # cpio uses copy-pass and may have just created a directory structure From patchwork Sat Aug 13 20:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 11362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DC10C3F6B0 for ; Sat, 13 Aug 2022 20:35:16 +0000 (UTC) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.groups.io with SMTP id smtpd.web09.8724.1660422906232708260 for ; Sat, 13 Aug 2022 13:35:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=UyunAGRy; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.41, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f41.google.com with SMTP id n4so4641470wrp.10 for ; Sat, 13 Aug 2022 13:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=51CrrLWdwFrBSdjUad5sLuuahz7vZLsIyPTzQ+N5J7M=; b=UyunAGRy/P8h+lLdxh6dWsxLy4EA4zmegNt9hs7taK8kvQI/Gshm7ClFpWRsIZHIBN XVogiyhhE6ibV4Q0aytBiQPaODBMrEAt+GCOd4oW+XxWyDHbizLq+Riv/eisoMuVAXYG wtPsj9nw8yiKFwamtXEmjIyaoAQvK1H8h67M8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=51CrrLWdwFrBSdjUad5sLuuahz7vZLsIyPTzQ+N5J7M=; b=klGvK6uOnuLgSX9sUr946Hk01f2atNpZi5eE8ujeYmOSTGNUL42INQrr6L6ds2NNNf Unxqcz22VP+4ClhZkAddHFjXE9kSj9kwjHMc+3N0UzDWPC0UvCOGu5Tdaf5AAD8fYobt U4RNLQ1KXasXsfsNXBDq1arrjOTwhXv81/ocRhSpEE04X3SgpjPQiF7OObAocul1hVG8 BIAN7SIRj/+EdL+qw452GiB1ROmN5PomMH+zTgOt5XnEQV0LuSSX8IvvCE2bL03CyhRw s2L7EEmWPVPbgpMxqFvzH2fCNuN+nOI3SkF18Z+4dcvGiRDmvdNE4cBJ5pLuetiBVidI 15Zg== X-Gm-Message-State: ACgBeo3AP5hw/Pnig3nYogaQB5MGA0s5FtKY6nAPI8OroyHBJ2ekF3/+ 1vkoZCdvuc0FoO5m3A17EacVHbdPsh62kw== X-Google-Smtp-Source: AA6agR75jA1+w9hjeGNuavSD0XreSFDjg5WXyUdV7jDhm6CmxZL9x+Xn/4RSQpyOc7tjRIg+RD3g7A== X-Received: by 2002:a5d:6852:0:b0:220:5c11:3cda with SMTP id o18-20020a5d6852000000b002205c113cdamr5017066wrw.592.1660422904047; Sat, 13 Aug 2022 13:35:04 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f6d8:ef31:d475:da8f]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a1980d55c4sm4182050wmq.47.2022.08.13.13.35.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 13:35:03 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/5] libgcc/gcc-runtime: Improve source reference handling Date: Sat, 13 Aug 2022 21:34:59 +0100 Message-Id: <20220813203501.1111519-3-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> References: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Aug 2022 20:35:16 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169315 This code was some of the earliest reproducible build work we did. To correctly handle the encoding of file paths, we used relative build paths to run configure which resulted in relative build paths in the binaries. We now have more modern approaches used elsewhere with the prefix remapping options. These work best with absolute paths, not relative ones. As such, drop the relative path mangling and switch to using prefix mapping exclusively on absolute paths. This makes the code matc the rest of the system and triggers the correct code to be added in /usr/src/debug. We have to include both file-prefix and debug-prefix since the assembler only looks at debug-prefix. Signed-off-by: Richard Purdie --- meta/recipes-devtools/gcc/gcc-runtime.inc | 22 ++++++++++----------- meta/recipes-devtools/gcc/libgcc-common.inc | 11 +++++++++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc index b8bfdcedadf..35a3077a4a7 100644 --- a/meta/recipes-devtools/gcc/gcc-runtime.inc +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc @@ -51,16 +51,15 @@ RUNTIMETARGET:libc-newlib = "libstdc++-v3" # libgfortran needs separate recipe due to libquadmath dependency # Relative path to be repaced into debug info -REL_S = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" - -DEBUG_PREFIX_MAP:class-target = " \ - -fdebug-prefix-map=${WORKDIR}/${MLPREFIX}recipe-sysroot= \ - -fdebug-prefix-map=${WORKDIR}/recipe-sysroot-native= \ - -fdebug-prefix-map=${S}=${REL_S} \ - -fdebug-prefix-map=${S}/include=${REL_S}/libstdc++-v3/../include \ - -fdebug-prefix-map=${S}/libiberty=${REL_S}/libstdc++-v3/../libiberty \ - -fdebug-prefix-map=${S}/libgcc=${REL_S}/libstdc++-v3/../libgcc \ - -fdebug-prefix-map=${B}=${REL_S} \ +DEBUGSOURCE = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" + +DEBUG_PREFIX_MAP = " \ + -ffile-prefix-map=${WORKDIR}/${MLPREFIX}recipe-sysroot= \ + -ffile-prefix-map=${WORKDIR}/recipe-sysroot-native= \ + -ffile-prefix-map=${B}=${DEBUGSOURCE} \ + -ffile-prefix-map=${S}=${DEBUGSOURCE} \ + -fdebug-prefix-map=${B}=${DEBUGSOURCE} \ + -fdebug-prefix-map=${S}=${DEBUGSOURCE} \ -ffile-prefix-map=${B}/${HOST_SYS}/libstdc++-v3/include=${includedir}/c++/${BINV} \ " @@ -77,8 +76,7 @@ do_configure () { mkdir -p ${B}/${TARGET_SYS}/$d/ cd ${B}/${TARGET_SYS}/$d/ chmod a+x ${S}/$d/configure - relpath=${@os.path.relpath("${S}/$d", "${B}/${TARGET_SYS}/$d")} - $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} + ${S}/$d/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} if [ "$d" = "libgcc" ]; then (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h) fi diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc index cf8d6b7ed6e..e8139263132 100644 --- a/meta/recipes-devtools/gcc/libgcc-common.inc +++ b/meta/recipes-devtools/gcc/libgcc-common.inc @@ -4,14 +4,21 @@ require gcc-configure-common.inc INHIBIT_DEFAULT_DEPS = "1" +DEBUGSOURCE = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" +DEBUG_PREFIX_MAP = " \ + -fdebug-prefix-map=${WORKDIR}/${MLPREFIX}recipe-sysroot= \ + -fdebug-prefix-map=${WORKDIR}/recipe-sysroot-native= \ + -fdebug-prefix-map=${B}=${DEBUGSOURCE} \ + -fdebug-prefix-map=${S}=${DEBUGSOURCE} \ + " + do_configure () { install -d ${D}${base_libdir} ${D}${libdir} mkdir -p ${B}/${BPN} mkdir -p ${B}/${TARGET_SYS}/${BPN}/ cd ${B}/${BPN} chmod a+x ${S}/${BPN}/configure - relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")} - $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} + ${S}/${BPN}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} } EXTRACONFFUNCS += "extract_stashed_builddir" do_configure[depends] += "${COMPILERDEP}" From patchwork Sat Aug 13 20:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 11361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CED8C19F2D for ; Sat, 13 Aug 2022 20:35:16 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.groups.io with SMTP id smtpd.web09.8725.1660422906775265820 for ; Sat, 13 Aug 2022 13:35:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=VzWS8DVz; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.52, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f52.google.com with SMTP id n4so4641495wrp.10 for ; Sat, 13 Aug 2022 13:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=cVDaQefTx1FNLwIEbxzuPvNDk2il0+RhFEGU8oqbjNU=; b=VzWS8DVzZT6i1XKvo7TTLPkiFCKBulwfF9WjNTbx4MVhk/Xf6PWyxsY9x9sJ2Zr9kk RpWWhZcN5yvy21IGeoOC+RFLs342r5p5uHD3YfBu8UgkU0cAbzL3h73mFtelcMkP5i50 0Fn8hoUzb0XG5kkoGu5UhdOgPsVKdfZZzkv6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=cVDaQefTx1FNLwIEbxzuPvNDk2il0+RhFEGU8oqbjNU=; b=Iu8M3vpMddEsXIEebbocB49cwP8c2xH2+q46EK4rhMlWpYab/LfmsAB1GdDjQSt35b FaoHEuiuCaOWdfUbsS2UPxTVYoW+azHCFzwz9FFcom2Esq5FNG+dkEog0HyE4Fxxb8OF nJk36wUtjyhbE3yMC5nSZooD8SKvCa1IsShmBwe2MPEyOMuzyG+aApPEpThZq0ogS1vv QmRi0bDs9Fng+sBZZFu6i3v+PVNamG6GA6LGo/wpnVTxFCZP0FfJpqJbzZBHCb7p91iJ AU/d43o+soZJ1LxSIMaV3SQxopzjpNuV2eFoOjM2upBFOkI2eqHyJTp9L9jSrvy+5BfH 9ncw== X-Gm-Message-State: ACgBeo0/gRA7HilAJBbZBpkiEPNFTWh6fkzPEOki6BaObtlZo262r7Wp QDa2ojDzf+fS2kh/xTiF4qA9sDVS3GU05g== X-Google-Smtp-Source: AA6agR79a8Dy6KPtpb2TK3gMfGeqdxCo90WzsBUkb2FApODyWuG20ikAKzXlmHBDK5cyujQa69P5aQ== X-Received: by 2002:a05:6000:186f:b0:222:c091:9c59 with SMTP id d15-20020a056000186f00b00222c0919c59mr5156585wri.78.1660422904921; Sat, 13 Aug 2022 13:35:04 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f6d8:ef31:d475:da8f]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a1980d55c4sm4182050wmq.47.2022.08.13.13.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 13:35:04 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 4/5] bitbake.conf: Handle S and B separately for debug mapping Date: Sat, 13 Aug 2022 21:35:00 +0100 Message-Id: <20220813203501.1111519-4-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> References: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Aug 2022 20:35:16 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169316 We don't really need to keep S and B separate for debug source purposes and there shouldn't be source references in WORKDIR that isn't S and B either. Separating these out simplifies the shared-work directory handling for gcc and should also help fix external source usage. Therefore handle S and B in DEBUG_PREFIX_MAP separately and clean up other code. Signed-off-by: Richard Purdie --- meta/conf/bitbake.conf | 11 +++++++---- meta/recipes-devtools/gcc/gcc-runtime.inc | 13 ------------- meta/recipes-devtools/gcc/libgcc-common.inc | 8 -------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index bdfb6784371..dd2df8a5520 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -645,10 +645,13 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " # Optimization flags. ################################################################## # Beware: applied last to first -DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ - -fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ - -fdebug-prefix-map=${STAGING_DIR_HOST}= \ - -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ +DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ + -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ + -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ + -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ + -fdebug-prefix-map=${STAGING_DIR_HOST}= \ + -fmacro-prefix-map=${STAGING_DIR_HOST}= \ + -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ " DEBUG_FLAGS ?= "-g -feliminate-unused-debug-types ${DEBUG_PREFIX_MAP}" diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc index 35a3077a4a7..fa5b048dab7 100644 --- a/meta/recipes-devtools/gcc/gcc-runtime.inc +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc @@ -50,19 +50,6 @@ RUNTIMETARGET:libc-newlib = "libstdc++-v3" # libiberty # libgfortran needs separate recipe due to libquadmath dependency -# Relative path to be repaced into debug info -DEBUGSOURCE = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" - -DEBUG_PREFIX_MAP = " \ - -ffile-prefix-map=${WORKDIR}/${MLPREFIX}recipe-sysroot= \ - -ffile-prefix-map=${WORKDIR}/recipe-sysroot-native= \ - -ffile-prefix-map=${B}=${DEBUGSOURCE} \ - -ffile-prefix-map=${S}=${DEBUGSOURCE} \ - -fdebug-prefix-map=${B}=${DEBUGSOURCE} \ - -fdebug-prefix-map=${S}=${DEBUGSOURCE} \ - -ffile-prefix-map=${B}/${HOST_SYS}/libstdc++-v3/include=${includedir}/c++/${BINV} \ - " - do_configure () { export CXX="${CXX} -nostdinc++ -L${WORKDIR}/dummylib" # libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc index e8139263132..d9084af51ad 100644 --- a/meta/recipes-devtools/gcc/libgcc-common.inc +++ b/meta/recipes-devtools/gcc/libgcc-common.inc @@ -4,14 +4,6 @@ require gcc-configure-common.inc INHIBIT_DEFAULT_DEPS = "1" -DEBUGSOURCE = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" -DEBUG_PREFIX_MAP = " \ - -fdebug-prefix-map=${WORKDIR}/${MLPREFIX}recipe-sysroot= \ - -fdebug-prefix-map=${WORKDIR}/recipe-sysroot-native= \ - -fdebug-prefix-map=${B}=${DEBUGSOURCE} \ - -fdebug-prefix-map=${S}=${DEBUGSOURCE} \ - " - do_configure () { install -d ${D}${base_libdir} ${D}${libdir} mkdir -p ${B}/${BPN} From patchwork Sat Aug 13 20:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 11363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40CF7C25B0F for ; Sat, 13 Aug 2022 20:35:16 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web09.8726.1660422907521787658 for ; Sat, 13 Aug 2022 13:35:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=V47I9r1Y; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.42, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f42.google.com with SMTP id v3so4705435wrp.0 for ; Sat, 13 Aug 2022 13:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=fiInH00GK9jkpm8Cx0VetHpuRkJgFr2ZgLQeb0pDF78=; b=V47I9r1YCXtWjljXEhi5qYoFBI/lrq6Yrn/RlneCPXGdfVzcTYVtCfVs+FUoiPklPZ Se9KgopK8yDkx79wM2AmlLv57hb7e3hpo2U3DH7Cl495z+kHOKhKDiV21v+xjMwJ10Ke 5P/Yw9BLnLr7ZG6etsb9EgbGArNFS2iJTSFz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=fiInH00GK9jkpm8Cx0VetHpuRkJgFr2ZgLQeb0pDF78=; b=wLe8ONmeoa5HwzDAXfu+GMrFfMNQF0OGv4iGIxV4ezL6wxvq+ukpXGGziB3Jz39xE8 3WAjzKzQzVup4seFA/oGXxYBGeNYKkjOQTEPjz8TwrdGPpPM3YsPtPrtL84htuVU6Fmv 2A3zbbTtSTVXpLzom5QR4QqFnbROm2IfiTAR0eYSWmHuyl7AvA+tAv50F1pI6lXcKQVc 02C+TDvfzJFxE9SzdNNNK1G7AkPuKjjUHG0i0VkmHDRhzW/x/0pFQ+4PMefjyQmTDVpq hQYwrjz9qK7E2GCSod7JenF0+v4gwXc/fTg5SwO84uUEg+jEzFz07PhYvupwAbZ0GRfZ HXSg== X-Gm-Message-State: ACgBeo0yjExc4PqW0AfnpvtVYfRTlAeVYWe5lagSV9VUkJgqZiCPhEhD VDwFhGbjxshW69RJVBfqQ3wkPcgVS3gNaw== X-Google-Smtp-Source: AA6agR7xIJl/QJDQXvDfZxA7L6AJ427r67UJ60HN+tciMFPN1NryoQDcIrkZRgEz8tpEC3WOqTWqIQ== X-Received: by 2002:a05:6000:2c1:b0:220:5f91:62de with SMTP id o1-20020a05600002c100b002205f9162demr5101999wry.715.1660422905755; Sat, 13 Aug 2022 13:35:05 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:f6d8:ef31:d475:da8f]) by smtp.gmail.com with ESMTPSA id l14-20020a05600c4f0e00b003a1980d55c4sm4182050wmq.47.2022.08.13.13.35.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 13:35:05 -0700 (PDT) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 5/5] gcc-cross: Fix relative links Date: Sat, 13 Aug 2022 21:35:01 +0100 Message-Id: <20220813203501.1111519-5-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> References: <20220813203501.1111519-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Aug 2022 20:35:16 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/169317 Now that we're using absolute paths to run configure, there are absolute path symlinks within gcc's output. Use our script that fixes these so that the sstate objects work correctly. Signed-off-by: Richard Purdie --- meta/recipes-devtools/gcc/gcc-cross.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc index 3ffa1f0c460..a540fb2434a 100644 --- a/meta/recipes-devtools/gcc/gcc-cross.inc +++ b/meta/recipes-devtools/gcc/gcc-cross.inc @@ -149,6 +149,7 @@ do_gcc_stash_builddir () { # Makefile does move-if-change which can end up with 'timestamp' as file contents so break links to those files rm $dest/gcc/include/*.h cp gcc/include/*.h $dest/gcc/include/ + sysroot-relativelinks.py $dest } addtask do_gcc_stash_builddir after do_compile before do_install SSTATETASKS += "do_gcc_stash_builddir"