[Bug 2002076] Re: stripping lto flags doesn't work as expected

Shengjing Zhu 2002076 at bugs.launchpad.net
Fri Jan 6 10:09:32 UTC 2023


The best is to write a smart regexp in dpkg. Or just workaround(yeah,
workaround on workarund, the lto strip is already a workaround) like:

```
diff -Nru dh-golang-1.59/lib/Debian/Debhelper/Buildsystem/golang.pm dh-golang-1.59ubuntu1/lib/Debian/Debhelper/Buildsystem/golang.pm
--- dh-golang-1.59/lib/Debian/Debhelper/Buildsystem/golang.pm	2022-09-25 11:28:07.000000000 +0000
+++ dh-golang-1.59ubuntu1/lib/Debian/Debhelper/Buildsystem/golang.pm	2023-01-06 09:59:50.000000000 +0000
@@ -380,6 +380,8 @@
     foreach my $flag (@flags) {
         if (! exists $ENV{"CGO_" . $flag}) {
             $bf->strip($flag, "-ffat-lto-objects -flto=auto");
+            # strip twice to workaround #1028044
+            $bf->strip($flag, "-ffat-lto-objects -flto=auto");
             # https://golang.org/issues/54313
             # https://github.com/golang/go/commit/365ca694
             $bf->strip($flag, "-fstack-protector-strong");
```

** Bug watch added: golang.org/issues #54313
   https://golang.org/issues/54313

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to dh-golang in Ubuntu.
https://bugs.launchpad.net/bugs/2002076

Title:
  stripping lto flags doesn't work as expected

Status in dh-golang package in Ubuntu:
  New
Status in dpkg package in Ubuntu:
  New

Bug description:
  In dh-golang, we use dpkg's C flags as Go's CGO flags. When dpkg's LTO
  feature is enabled, the LTO C flags may pass to CGO as well. But Go's
  linker doesn't support LTO. So in dh-golang, we implemented a
  workround to strip LTO flag[1].

  [1] https://salsa.debian.org/go-team/packages/dh-
  golang/-/commit/501517bca24c155bdd3ed706ad413a22c625c7a8

  ```
  $bf->strip($flag, "-ffat-lto-objects -flto=auto");
  ```

  This works well in Debian, but it turns out not robust for Ubuntu.

  In Ubuntu, we get such C flags:

  ```
  $ dpkg-buildflags --get CFLAGS
  -g -O2 -ffile-prefix-map=[redacted]=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security

  ```

  It has two duplicated `-flto=auto -ffat-lto-objects`. So dh-golang's
  code doesn't handle it robustly. One `-flto=auto -ffat-lto-objects`
  set is still passed to CGO. This causes link error.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dh-golang/+bug/2002076/+subscriptions




More information about the foundations-bugs mailing list