#31 Add -trimpath
Closed a year ago by alexsaezm. Opened a year ago by alexsaezm.
Unknown source master  into  master

@@ -26,7 +26,7 @@

  # Define commands for building

  %gobuild(o:) %{expand:

  %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} \\

- go build -compiler gccgo -gccgoflags     "$RPM_OPT_FLAGS ${LDFLAGS:-%{?currentgoldflags} %__global_ldflags} %{?__golang_extldflags}" -a -v -x %{?**};

+ go build -trimpath -compiler gccgo -gccgoflags     "$RPM_OPT_FLAGS ${LDFLAGS:-%{?currentgoldflags} %__global_ldflags} %{?__golang_extldflags}" -a -v -x %{?**};

  }

  

  # Define commands for testing

@@ -40,7 +40,7 @@

    # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12

    %global _dwz_low_mem_die_limit 0

    %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\

-   go build %{?gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};

+   go build %{?gocompilerflags} -trimpath -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} %{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};

  }

  ${workroot}${GOPATH:+:${GOPATH}}

  

Any suggestions @eclipseo ? I'm not quite sure about including it in the %{?gocompilerflags} because it is used in go test and -trimpath is just for go build but I see duplicated flags so not really sure.

Also, do you think this could affect somehow the builds? Can't think of anything but better safe than sorry.

This seems okay to me as is, but I don't know if it could affect the builds. A beta test in COPR might be useful.

You should probably edit %gobuildflags() too?

I've tested some builds in a COPR: https://copr.fedorainfracloud.org/coprs/eclipseo/trimpath/builds/

They all fail, apparently no debuginfo are generated.

After considering it and talking with coworkers about why this flag was not included before, I think it doesn't make any sense, mainly because Koji builds in a sanitized build root, so nothing to leak. The same thing goes for reproducible builds.

I'll add a comment to the issue just in case there's something I'm missing. But otherwise, I think I should drop my PR :smile:

Pull-Request has been closed by alexsaezm

a year ago