Bug 2055863

Summary: package-notes causes different %{__global_ldflags} between %prep and %build
Product: [Fedora] Fedora Reporter: Hans de Goede <hdegoede>
Component: package-notesAssignee: Zbigniew Jędrzejewski-Szmek <zbyszek>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: devrim, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: package-notes-0.5-4.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-03 16:26:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2099999    
Bug Blocks:    

Description Hans de Goede 2022-02-17 20:11:55 UTC
I noticed that package-notes causes different %{__global_ldflags} between %prep and %build.

This is causing a build failure with openmsx for Fedora 36:
https://koji.fedoraproject.org/koji/taskinfo?taskID=82623076

With the error being:
/usr/bin/ld: cannot open linker script file /builddir/build/BUILD/.package_note-openmsx-16.0-5.fc36.x86_64.ld: No such file or directory

The problem is that openmsx uses its own buildsystem written in python and openmsx.spec does the following to generate config files for a "rpm" flavor for openmsx in %setup:

"""
cat > build/flavour-rpm.mk << EOF
# Opt flags.
CXXFLAGS+=%{optflags} -DNDEBUG
LINK_FLAGS+=%{__global_ldflags}

# Dont strip exe, let rpm do it and save debug info
OPENMSX_STRIP:=false
CATAPULT_STRIP:=false
EOF
"""

This results in the troublesome:

/builddir/build/BUILD/.package_note-openmsx-16.0-5.fc36.x86_64.ld

path making it into build/flavour-rpm.mk, where as during %build the file actually gets generated as:

/builddir/build/BUILD/openmsx-16.0/.package_note-openmsx-16.0-5.fc36.x86_64.ld

I assume the issue is %setup is setting the openmsx-16.0 part of the path and that this is not set when the macros in the %prep step get expanded.

For now I've fixed this by just moving the above generation of build/flavour-rpm.mk to %build. But I still thought you should be aware of this issue. At a minimum this issue should be documented somewhere.

Comment 1 Zbigniew Jędrzejewski-Szmek 2022-02-18 08:15:56 UTC
Yes, this is a well-known issue without a good solution so far.
In particular this prompted a cleanup to move all calls from %configure from %prep to %build.
But calling %configure in %prep is wrong for other reasons, while saving link flags like
you'd like to do here is OK and should work.

I'll keep this open for now. I think it'd be easiest to enhance rpm to provide %buildsubdir
earlier, or something equivalent.

Comment 2 Devrim Gündüz 2022-05-17 21:00:12 UTC
This bites every PostgreSQL extension packages that I'm building . Any progress so far?

Thanks! Devrim

Comment 3 Zbigniew Jędrzejewski-Szmek 2022-08-09 09:31:29 UTC
This should be fixed with the new approach in #2099999.

Comment 4 Zbigniew Jędrzejewski-Szmek 2022-09-03 16:26:33 UTC
This should be resolved with the new approach used in F37+. We'll not be changing the implementation
in F36 though, since that'd be likely to cause regressions.