diff mbox series

fwts-22.03.00 build fix patch

Message ID 20220511094320.22779bf8@Akita
State Superseded
Headers show
Series fwts-22.03.00 build fix patch | expand

Commit Message

orbea May 11, 2022, 4:43 p.m. UTC
Hi,

When building fwts with slibtool
(https://dev.midipix.org/cross/slibtool) the build fail with undefined
references. This is because the build system is using -lfoo linker
flags for internal dependencies instead of using the libtool archive
(.la) files instead. Additionally there are several instances of
hardcoded pkg-config calls and linker flags in LDFLAGS rather than
LIBADD and LDADD.

I attached a patch that fixes the issues by doing a few things.

* Removed hardcoded pkg-config calls and replaced them with
  PKG_CHECK_MODULES as needed.

* Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems should
  only add non-dependency linker flags to LDFLAGS while LDADD and
  LIBADD should be for any required dependencies.

* Removed any -lfoo linker flags for internal dependencies and added
  them as .la files to link the fwts binary which now uses
  -no-undefined. Using -lfoo linker flags should be only for external
  dependencies and often results in undefined errors or the linker
  flags entirely not found with slibtool. Slibtool is far more strict
  about user error than GNU libtool which often silently hides such
  issues.

* Cleared out a few unneeded or redundant linker flags.

Gentoo bug: https://bugs.gentoo.org/780372

Comments

Ivan Hu May 16, 2022, 6:48 a.m. UTC | #1
This modification make build fail on my machine.


Cheers,

Ivan

On 5/12/22 00:43, orbea wrote:
> Hi,
>
> When building fwts with slibtool
> (https://dev.midipix.org/cross/slibtool) the build fail with undefined
> references. This is because the build system is using -lfoo linker
> flags for internal dependencies instead of using the libtool archive
> (.la) files instead. Additionally there are several instances of
> hardcoded pkg-config calls and linker flags in LDFLAGS rather than
> LIBADD and LDADD.
>
> I attached a patch that fixes the issues by doing a few things.
>
> * Removed hardcoded pkg-config calls and replaced them with
>   PKG_CHECK_MODULES as needed.
>
> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems should
>   only add non-dependency linker flags to LDFLAGS while LDADD and
>   LIBADD should be for any required dependencies.
>
> * Removed any -lfoo linker flags for internal dependencies and added
>   them as .la files to link the fwts binary which now uses
>   -no-undefined. Using -lfoo linker flags should be only for external
>   dependencies and often results in undefined errors or the linker
>   flags entirely not found with slibtool. Slibtool is far more strict
>   about user error than GNU libtool which often silently hides such
>   issues.
>
> * Cleared out a few unneeded or redundant linker flags.
>
> Gentoo bug: https://bugs.gentoo.org/780372
>
orbea May 16, 2022, 1:37 p.m. UTC | #2
Can you please share the build log? Perhaps I can find a better way to
do something?

On Mon, 16 May 2022 14:48:16 +0800
ivanhu <ivan.hu@canonical.com> wrote:

> This modification make build fail on my machine.
> 
> 
> Cheers,
> 
> Ivan
> 
> On 5/12/22 00:43, orbea wrote:
> > Hi,
> >
> > When building fwts with slibtool
> > (https://dev.midipix.org/cross/slibtool) the build fail with
> > undefined references. This is because the build system is using
> > -lfoo linker flags for internal dependencies instead of using the
> > libtool archive (.la) files instead. Additionally there are several
> > instances of hardcoded pkg-config calls and linker flags in LDFLAGS
> > rather than LIBADD and LDADD.
> >
> > I attached a patch that fixes the issues by doing a few things.
> >
> > * Removed hardcoded pkg-config calls and replaced them with
> >   PKG_CHECK_MODULES as needed.
> >
> > * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems
> > should only add non-dependency linker flags to LDFLAGS while LDADD
> > and LIBADD should be for any required dependencies.
> >
> > * Removed any -lfoo linker flags for internal dependencies and added
> >   them as .la files to link the fwts binary which now uses
> >   -no-undefined. Using -lfoo linker flags should be only for
> > external dependencies and often results in undefined errors or the
> > linker flags entirely not found with slibtool. Slibtool is far more
> > strict about user error than GNU libtool which often silently hides
> > such issues.
> >
> > * Cleared out a few unneeded or redundant linker flags.
> >
> > Gentoo bug: https://bugs.gentoo.org/780372
> >
Ivan Hu May 17, 2022, 8:51 a.m. UTC | #3
I create a test build for all arch, you can check on
https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages

For the amd64 build log for jammy,
https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz


Cheers,
Ivan

On 5/16/22 21:37, orbea wrote:
> Can you please share the build log? Perhaps I can find a better way to
> do something?
>
> On Mon, 16 May 2022 14:48:16 +0800
> ivanhu <ivan.hu@canonical.com> wrote:
>
>> This modification make build fail on my machine.
>>
>>
>> Cheers,
>>
>> Ivan
>>
>> On 5/12/22 00:43, orbea wrote:
>>> Hi,
>>>
>>> When building fwts with slibtool
>>> (https://dev.midipix.org/cross/slibtool) the build fail with
>>> undefined references. This is because the build system is using
>>> -lfoo linker flags for internal dependencies instead of using the
>>> libtool archive (.la) files instead. Additionally there are several
>>> instances of hardcoded pkg-config calls and linker flags in LDFLAGS
>>> rather than LIBADD and LDADD.
>>>
>>> I attached a patch that fixes the issues by doing a few things.
>>>
>>> * Removed hardcoded pkg-config calls and replaced them with
>>>    PKG_CHECK_MODULES as needed.
>>>
>>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems
>>> should only add non-dependency linker flags to LDFLAGS while LDADD
>>> and LIBADD should be for any required dependencies.
>>>
>>> * Removed any -lfoo linker flags for internal dependencies and added
>>>    them as .la files to link the fwts binary which now uses
>>>    -no-undefined. Using -lfoo linker flags should be only for
>>> external dependencies and often results in undefined errors or the
>>> linker flags entirely not found with slibtool. Slibtool is far more
>>> strict about user error than GNU libtool which often silently hides
>>> such issues.
>>>
>>> * Cleared out a few unneeded or redundant linker flags.
>>>
>>> Gentoo bug: https://bugs.gentoo.org/780372
>>>
orbea May 17, 2022, 7:12 p.m. UTC | #4
Thank you, that was very helpful. I attached a new patch, can you
please try again?

I think the problem was that I accidentally forgot AC_SUBST in
configure.ac which passes the GIO_LIBS and GLIB_LIBS variables to the
Makefiles. I'm surprised it worked for me at all without this...

On Tue, 17 May 2022 16:51:55 +0800
ivanhu <ivan.hu@canonical.com> wrote:

> I create a test build for all arch, you can check on
> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
> 
> For the amd64 build log for jammy,
> https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz
> 
> 
> Cheers,
> Ivan
> 
> On 5/16/22 21:37, orbea wrote:
> > Can you please share the build log? Perhaps I can find a better way
> > to do something?
> >
> > On Mon, 16 May 2022 14:48:16 +0800
> > ivanhu <ivan.hu@canonical.com> wrote:
> >  
> >> This modification make build fail on my machine.
> >>
> >>
> >> Cheers,
> >>
> >> Ivan
> >>
> >> On 5/12/22 00:43, orbea wrote:  
> >>> Hi,
> >>>
> >>> When building fwts with slibtool
> >>> (https://dev.midipix.org/cross/slibtool) the build fail with
> >>> undefined references. This is because the build system is using
> >>> -lfoo linker flags for internal dependencies instead of using the
> >>> libtool archive (.la) files instead. Additionally there are
> >>> several instances of hardcoded pkg-config calls and linker flags
> >>> in LDFLAGS rather than LIBADD and LDADD.
> >>>
> >>> I attached a patch that fixes the issues by doing a few things.
> >>>
> >>> * Removed hardcoded pkg-config calls and replaced them with
> >>>    PKG_CHECK_MODULES as needed.
> >>>
> >>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems
> >>> should only add non-dependency linker flags to LDFLAGS while LDADD
> >>> and LIBADD should be for any required dependencies.
> >>>
> >>> * Removed any -lfoo linker flags for internal dependencies and
> >>> added them as .la files to link the fwts binary which now uses
> >>>    -no-undefined. Using -lfoo linker flags should be only for
> >>> external dependencies and often results in undefined errors or the
> >>> linker flags entirely not found with slibtool. Slibtool is far
> >>> more strict about user error than GNU libtool which often
> >>> silently hides such issues.
> >>>
> >>> * Cleared out a few unneeded or redundant linker flags.
> >>>
> >>> Gentoo bug: https://bugs.gentoo.org/780372
> >>>
Ivan Hu May 18, 2022, 2:33 p.m. UTC | #5
Still all build fail, you can check on

https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages

It may be a good idea if you can create a folder/script for slibtool build like fedora rpm build with FWTS, instead of directly modifying configure.ac
and makefile.am. It is easier for you to maintain and won't affect the other architectures build.


Cheers,
Ivan

On 5/18/22 03:12, orbea wrote:
> Thank you, that was very helpful. I attached a new patch, can you
> please try again?
>
> I think the problem was that I accidentally forgot AC_SUBST in
> configure.ac which passes the GIO_LIBS and GLIB_LIBS variables to the
> Makefiles. I'm surprised it worked for me at all without this...
>
> On Tue, 17 May 2022 16:51:55 +0800
> ivanhu <ivan.hu@canonical.com> wrote:
>
>> I create a test build for all arch, you can check on
>> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
>>
>> For the amd64 build log for jammy,
>> https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz
>>
>>
>> Cheers,
>> Ivan
>>
>> On 5/16/22 21:37, orbea wrote:
>>> Can you please share the build log? Perhaps I can find a better way
>>> to do something?
>>>
>>> On Mon, 16 May 2022 14:48:16 +0800
>>> ivanhu <ivan.hu@canonical.com> wrote:
>>>   
>>>> This modification make build fail on my machine.
>>>>
>>>>
>>>> Cheers,
>>>>
>>>> Ivan
>>>>
>>>> On 5/12/22 00:43, orbea wrote:
>>>>> Hi,
>>>>>
>>>>> When building fwts with slibtool
>>>>> (https://dev.midipix.org/cross/slibtool) the build fail with
>>>>> undefined references. This is because the build system is using
>>>>> -lfoo linker flags for internal dependencies instead of using the
>>>>> libtool archive (.la) files instead. Additionally there are
>>>>> several instances of hardcoded pkg-config calls and linker flags
>>>>> in LDFLAGS rather than LIBADD and LDADD.
>>>>>
>>>>> I attached a patch that fixes the issues by doing a few things.
>>>>>
>>>>> * Removed hardcoded pkg-config calls and replaced them with
>>>>>     PKG_CHECK_MODULES as needed.
>>>>>
>>>>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems
>>>>> should only add non-dependency linker flags to LDFLAGS while LDADD
>>>>> and LIBADD should be for any required dependencies.
>>>>>
>>>>> * Removed any -lfoo linker flags for internal dependencies and
>>>>> added them as .la files to link the fwts binary which now uses
>>>>>     -no-undefined. Using -lfoo linker flags should be only for
>>>>> external dependencies and often results in undefined errors or the
>>>>> linker flags entirely not found with slibtool. Slibtool is far
>>>>> more strict about user error than GNU libtool which often
>>>>> silently hides such issues.
>>>>>
>>>>> * Cleared out a few unneeded or redundant linker flags.
>>>>>
>>>>> Gentoo bug: https://bugs.gentoo.org/780372
>>>>>
orbea May 18, 2022, 3:34 p.m. UTC | #6
Thank you for testing! I attached one more version of the patch that I
think should fix the remaining issue. I would really appreciate it if
you can test it again.

My last version of the patch fixed most of the issues and only one more
is left. I think this is because I was overzealous in removing -lbsd
when linking the fwts binary. Adding it back should get the build to
build completely this time.

It is surprising to me how much the difference between gentoo and
ubuntu can matter here even when I test with GNU libtool, but I think it
should be possible to find a solution that works for everyone. :)

On Wed, 18 May 2022 22:33:00 +0800
ivanhu <ivan.hu@canonical.com> wrote:

> Still all build fail, you can check on
> 
> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
> 
> It may be a good idea if you can create a folder/script for slibtool
> build like fedora rpm build with FWTS, instead of directly modifying
> configure.ac and makefile.am. It is easier for you to maintain and
> won't affect the other architectures build.
> 
> 
> Cheers,
> Ivan
> 
> On 5/18/22 03:12, orbea wrote:
> > Thank you, that was very helpful. I attached a new patch, can you
> > please try again?
> >
> > I think the problem was that I accidentally forgot AC_SUBST in
> > configure.ac which passes the GIO_LIBS and GLIB_LIBS variables to
> > the Makefiles. I'm surprised it worked for me at all without this...
> >
> > On Tue, 17 May 2022 16:51:55 +0800
> > ivanhu <ivan.hu@canonical.com> wrote:
> >  
> >> I create a test build for all arch, you can check on
> >> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
> >>
> >> For the amd64 build log for jammy,
> >> https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz
> >>
> >>
> >> Cheers,
> >> Ivan
> >>
> >> On 5/16/22 21:37, orbea wrote:  
> >>> Can you please share the build log? Perhaps I can find a better
> >>> way to do something?
> >>>
> >>> On Mon, 16 May 2022 14:48:16 +0800
> >>> ivanhu <ivan.hu@canonical.com> wrote:
> >>>     
> >>>> This modification make build fail on my machine.
> >>>>
> >>>>
> >>>> Cheers,
> >>>>
> >>>> Ivan
> >>>>
> >>>> On 5/12/22 00:43, orbea wrote:  
> >>>>> Hi,
> >>>>>
> >>>>> When building fwts with slibtool
> >>>>> (https://dev.midipix.org/cross/slibtool) the build fail with
> >>>>> undefined references. This is because the build system is using
> >>>>> -lfoo linker flags for internal dependencies instead of using
> >>>>> the libtool archive (.la) files instead. Additionally there are
> >>>>> several instances of hardcoded pkg-config calls and linker flags
> >>>>> in LDFLAGS rather than LIBADD and LDADD.
> >>>>>
> >>>>> I attached a patch that fixes the issues by doing a few things.
> >>>>>
> >>>>> * Removed hardcoded pkg-config calls and replaced them with
> >>>>>     PKG_CHECK_MODULES as needed.
> >>>>>
> >>>>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build systems
> >>>>> should only add non-dependency linker flags to LDFLAGS while
> >>>>> LDADD and LIBADD should be for any required dependencies.
> >>>>>
> >>>>> * Removed any -lfoo linker flags for internal dependencies and
> >>>>> added them as .la files to link the fwts binary which now uses
> >>>>>     -no-undefined. Using -lfoo linker flags should be only for
> >>>>> external dependencies and often results in undefined errors or
> >>>>> the linker flags entirely not found with slibtool. Slibtool is
> >>>>> far more strict about user error than GNU libtool which often
> >>>>> silently hides such issues.
> >>>>>
> >>>>> * Cleared out a few unneeded or redundant linker flags.
> >>>>>
> >>>>> Gentoo bug: https://bugs.gentoo.org/780372
> >>>>>
orbea May 27, 2022, 8:34 p.m. UTC | #7
Hi Ivan,

I would really appreciate it if you can test the latest version of the
patch!

On Wed, 18 May 2022 08:34:34 -0700
orbea <orbea@riseup.net> wrote:

> Thank you for testing! I attached one more version of the patch that I
> think should fix the remaining issue. I would really appreciate it if
> you can test it again.
> 
> My last version of the patch fixed most of the issues and only one
> more is left. I think this is because I was overzealous in removing
> -lbsd when linking the fwts binary. Adding it back should get the
> build to build completely this time.
> 
> It is surprising to me how much the difference between gentoo and
> ubuntu can matter here even when I test with GNU libtool, but I think
> it should be possible to find a solution that works for everyone. :)
> 
> On Wed, 18 May 2022 22:33:00 +0800
> ivanhu <ivan.hu@canonical.com> wrote:
> 
> > Still all build fail, you can check on
> > 
> > https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
> > 
> > It may be a good idea if you can create a folder/script for slibtool
> > build like fedora rpm build with FWTS, instead of directly modifying
> > configure.ac and makefile.am. It is easier for you to maintain and
> > won't affect the other architectures build.
> > 
> > 
> > Cheers,
> > Ivan
> > 
> > On 5/18/22 03:12, orbea wrote:  
> > > Thank you, that was very helpful. I attached a new patch, can you
> > > please try again?
> > >
> > > I think the problem was that I accidentally forgot AC_SUBST in
> > > configure.ac which passes the GIO_LIBS and GLIB_LIBS variables to
> > > the Makefiles. I'm surprised it worked for me at all without
> > > this...
> > >
> > > On Tue, 17 May 2022 16:51:55 +0800
> > > ivanhu <ivan.hu@canonical.com> wrote:
> > >    
> > >> I create a test build for all arch, you can check on
> > >> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
> > >>
> > >> For the amd64 build log for jammy,
> > >> https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz
> > >>
> > >>
> > >> Cheers,
> > >> Ivan
> > >>
> > >> On 5/16/22 21:37, orbea wrote:    
> > >>> Can you please share the build log? Perhaps I can find a better
> > >>> way to do something?
> > >>>
> > >>> On Mon, 16 May 2022 14:48:16 +0800
> > >>> ivanhu <ivan.hu@canonical.com> wrote:
> > >>>       
> > >>>> This modification make build fail on my machine.
> > >>>>
> > >>>>
> > >>>> Cheers,
> > >>>>
> > >>>> Ivan
> > >>>>
> > >>>> On 5/12/22 00:43, orbea wrote:    
> > >>>>> Hi,
> > >>>>>
> > >>>>> When building fwts with slibtool
> > >>>>> (https://dev.midipix.org/cross/slibtool) the build fail with
> > >>>>> undefined references. This is because the build system is
> > >>>>> using -lfoo linker flags for internal dependencies instead of
> > >>>>> using the libtool archive (.la) files instead. Additionally
> > >>>>> there are several instances of hardcoded pkg-config calls and
> > >>>>> linker flags in LDFLAGS rather than LIBADD and LDADD.
> > >>>>>
> > >>>>> I attached a patch that fixes the issues by doing a few
> > >>>>> things.
> > >>>>>
> > >>>>> * Removed hardcoded pkg-config calls and replaced them with
> > >>>>>     PKG_CHECK_MODULES as needed.
> > >>>>>
> > >>>>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build
> > >>>>> systems should only add non-dependency linker flags to
> > >>>>> LDFLAGS while LDADD and LIBADD should be for any required
> > >>>>> dependencies.
> > >>>>>
> > >>>>> * Removed any -lfoo linker flags for internal dependencies and
> > >>>>> added them as .la files to link the fwts binary which now uses
> > >>>>>     -no-undefined. Using -lfoo linker flags should be only for
> > >>>>> external dependencies and often results in undefined errors or
> > >>>>> the linker flags entirely not found with slibtool. Slibtool is
> > >>>>> far more strict about user error than GNU libtool which often
> > >>>>> silently hides such issues.
> > >>>>>
> > >>>>> * Cleared out a few unneeded or redundant linker flags.
> > >>>>>
> > >>>>> Gentoo bug: https://bugs.gentoo.org/780372
> > >>>>>          
>
Ivan Hu May 31, 2022, 7:44 a.m. UTC | #8
Hi Orbea,

I resent your last patch with correct commit format which can be applied
to FWTS for testing.

http://patchwork.ozlabs.org/project/fwts/patch/20220531074030.8151-1-ivan.hu@canonical.com/

Please check on it, then we can do the review and testing.

Cheers,
Ivan

On 5/28/22 04:34, orbea wrote:
> Hi Ivan,
>
> I would really appreciate it if you can test the latest version of the
> patch!
>
> On Wed, 18 May 2022 08:34:34 -0700
> orbea <orbea@riseup.net> wrote:
>
>> Thank you for testing! I attached one more version of the patch that I
>> think should fix the remaining issue. I would really appreciate it if
>> you can test it again.
>>
>> My last version of the patch fixed most of the issues and only one
>> more is left. I think this is because I was overzealous in removing
>> -lbsd when linking the fwts binary. Adding it back should get the
>> build to build completely this time.
>>
>> It is surprising to me how much the difference between gentoo and
>> ubuntu can matter here even when I test with GNU libtool, but I think
>> it should be possible to find a solution that works for everyone. :)
>>
>> On Wed, 18 May 2022 22:33:00 +0800
>> ivanhu <ivan.hu@canonical.com> wrote:
>>
>>> Still all build fail, you can check on
>>>
>>> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
>>>
>>> It may be a good idea if you can create a folder/script for slibtool
>>> build like fedora rpm build with FWTS, instead of directly modifying
>>> configure.ac and makefile.am. It is easier for you to maintain and
>>> won't affect the other architectures build.
>>>
>>>
>>> Cheers,
>>> Ivan
>>>
>>> On 5/18/22 03:12, orbea wrote:  
>>>> Thank you, that was very helpful. I attached a new patch, can you
>>>> please try again?
>>>>
>>>> I think the problem was that I accidentally forgot AC_SUBST in
>>>> configure.ac which passes the GIO_LIBS and GLIB_LIBS variables to
>>>> the Makefiles. I'm surprised it worked for me at all without
>>>> this...
>>>>
>>>> On Tue, 17 May 2022 16:51:55 +0800
>>>> ivanhu <ivan.hu@canonical.com> wrote:
>>>>    
>>>>> I create a test build for all arch, you can check on
>>>>> https://launchpad.net/~firmware-testing-team/+archive/ubuntu/scratch/+packages
>>>>>
>>>>> For the amd64 build log for jammy,
>>>>> https://launchpadlibrarian.net/601665740/buildlog_ubuntu-jammy-amd64.fwts_22.03.01-0ubuntu1~j_BUILDING.txt.gz
>>>>>
>>>>>
>>>>> Cheers,
>>>>> Ivan
>>>>>
>>>>> On 5/16/22 21:37, orbea wrote:    
>>>>>> Can you please share the build log? Perhaps I can find a better
>>>>>> way to do something?
>>>>>>
>>>>>> On Mon, 16 May 2022 14:48:16 +0800
>>>>>> ivanhu <ivan.hu@canonical.com> wrote:
>>>>>>       
>>>>>>> This modification make build fail on my machine.
>>>>>>>
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Ivan
>>>>>>>
>>>>>>> On 5/12/22 00:43, orbea wrote:    
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> When building fwts with slibtool
>>>>>>>> (https://dev.midipix.org/cross/slibtool) the build fail with
>>>>>>>> undefined references. This is because the build system is
>>>>>>>> using -lfoo linker flags for internal dependencies instead of
>>>>>>>> using the libtool archive (.la) files instead. Additionally
>>>>>>>> there are several instances of hardcoded pkg-config calls and
>>>>>>>> linker flags in LDFLAGS rather than LIBADD and LDADD.
>>>>>>>>
>>>>>>>> I attached a patch that fixes the issues by doing a few
>>>>>>>> things.
>>>>>>>>
>>>>>>>> * Removed hardcoded pkg-config calls and replaced them with
>>>>>>>>     PKG_CHECK_MODULES as needed.
>>>>>>>>
>>>>>>>> * Clearly delimited LDFLAGS from LDADD and LIBADD. Build
>>>>>>>> systems should only add non-dependency linker flags to
>>>>>>>> LDFLAGS while LDADD and LIBADD should be for any required
>>>>>>>> dependencies.
>>>>>>>>
>>>>>>>> * Removed any -lfoo linker flags for internal dependencies and
>>>>>>>> added them as .la files to link the fwts binary which now uses
>>>>>>>>     -no-undefined. Using -lfoo linker flags should be only for
>>>>>>>> external dependencies and often results in undefined errors or
>>>>>>>> the linker flags entirely not found with slibtool. Slibtool is
>>>>>>>> far more strict about user error than GNU libtool which often
>>>>>>>> silently hides such issues.
>>>>>>>>
>>>>>>>> * Cleared out a few unneeded or redundant linker flags.
>>>>>>>>
>>>>>>>> Gentoo bug: https://bugs.gentoo.org/780372
>>>>>>>>
diff mbox series

Patch

From 47bc82375865e2548edcb1607ca52ec60d632123 Mon Sep 17 00:00:00 2001
From: orbea <orbea@riseup.net>
Date: Tue, 10 May 2022 20:35:01 -0700
Subject: [PATCH 1/2] build: Improve linking

This improves the linking enough to get the build to complete
with slibtool and GNU libtool.
---
 configure.ac                  |  2 ++
 src/Makefile.am               | 20 ++++++++++----------
 src/lib/src/Makefile.am       | 18 ++++++++++--------
 src/libfwtsacpica/Makefile.am |  7 ++-----
 src/libfwtsiasl/Makefile.am   |  4 ++--
 5 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index f40c367..7ee5604 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,8 @@ 
 	  AC_CHECK_HEADERS([asm/opal-prd.h])
 	  AC_CHECK_HEADERS([mtd/mtd-abi.h])
 	  AC_CHECK_HEADERS([pci/pci.h])
+	  PKG_CHECK_MODULES([GIO], [gio-2.0])
+	  PKG_CHECK_MODULES([GLIB], [glib-2.0])
 	  AM_CONDITIONAL([HAVE_ASM_OPAL_PRD_H],
 	    [test "x$ac_cv_header_asm_opal_prd_h" = "xyes"])
 	  AM_CONDITIONAL([HAVE_MTD_ABI_H],
diff --git a/src/Makefile.am b/src/Makefile.am
index 9a26af8..e2180e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/acpica/source/compiler	\
 	-I$(top_srcdir)/efi_runtime			\
 	-I$(top_srcdir)/smccc_test			\
-	-pthread `pkg-config --cflags glib-2.0 gio-2.0` \
+	-pthread					\
 	-Wall -Werror -Wextra				\
 	-Wno-address-of-packed-member			\
 	-Wfloat-equal -Wmissing-declarations		\
@@ -23,7 +23,11 @@  AM_CPPFLAGS = \
 
 bin_PROGRAMS = fwts
 
-fwts_CPPFLAGS = $(AM_CPPFLAGS) -DACPI_DEBUG_OUTPUT
+fwts_CPPFLAGS = 					\
+	$(AM_CPPFLAGS)					\
+	@GIO_CFLAGS@					\
+	@GLIB_CFLAGS@					\
+	-DACPI_DEBUG_OUTPUT
 
 if HAVE_LIBFDT
 dt_tests = \
@@ -207,16 +211,12 @@  fwts_SOURCES = main.c 				\
 	$(power_mgmt_tests)			\
 	$(dt_tests)
 
-fwts_LDFLAGS = -lm -lbsd `pkg-config --libs glib-2.0 gio-2.0`
+fwts_LDFLAGS = -no-undefined
 
 fwts_LDADD = \
-	-lfwts					\
-	-L$(top_builddir)/src			\
-	-L$(top_builddir)/src/acpica		\
-	-L$(top_builddir)/src/libfwtsiasl	\
-	-L$(top_builddir)/src/libfwtsacpica	\
-	-L$(top_builddir)/src/lib/src		\
-	-lfwtsacpica
+	$(top_builddir)/src/lib/src/libfwts.la \
+	$(top_builddir)/src/libfwtsiasl/libfwtsiasl.la \
+	$(top_builddir)/src/libfwtsacpica/libfwtsacpica.la
 
 man_MANS = ../doc/fwts.1 ../doc/fwts-collect.1 ../doc/fwts-frontend-text.1
 
diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
index 0a39882..94bfcdf 100644
--- a/src/lib/src/Makefile.am
+++ b/src/lib/src/Makefile.am
@@ -21,22 +21,24 @@  AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/libfwtsiasl			\
 	-I$(top_srcdir)/src/acpica/source/include	\
 	-I$(top_srcdir)/src/acpica/source/compiler	\
-	`pkg-config --silence-errors --cflags json`	\
-	`pkg-config --silence-errors --cflags json-c`	\
-	`pkg-config --cflags glib-2.0 gio-2.0` 		\
 	-DDATAROOTDIR=\"$(datarootdir)\"		\
 	-Wall -Werror -Wextra				\
 	-Wno-address-of-packed-member
 
 pkglib_LTLIBRARIES = libfwts.la
 
-libfwts_la_LDFLAGS = 					\
+libfwts_la_LDFLAGS = -version-info 1:0:0
+
+libfwts_la_LIBADD = 					\
 	-lm -lpthread -lbsd				\
-	-version-info 1:0:0 				\
-	-L$(top_builddir)/src/libfwtsiasl		\
-	-lfwtsiasl `pkg-config --libs glib-2.0 gio-2.0`
+	@GIO_LIBS@					\
+	@GLIB_LIBS@
 
-libfwts_la_CPPFLAGS = $(AM_CPPFLAGS) -DACPI_DEBUG_OUTPUT
+libfwts_la_CPPFLAGS =					\
+	$(AM_CPPFLAGS)					\
+	@GIO_CFLAGS@					\
+	@GLIB_CFLAGS@					\
+	-DACPI_DEBUG_OUTPUT
 
 if HAVE_LIBFDT
 dt_sources = \
diff --git a/src/libfwtsacpica/Makefile.am b/src/libfwtsacpica/Makefile.am
index f37f585..62f0d8c 100644
--- a/src/libfwtsacpica/Makefile.am
+++ b/src/libfwtsacpica/Makefile.am
@@ -74,7 +74,8 @@  CLEANFILES = osunixxf_munged.c					\
 
 pkglib_LTLIBRARIES = libfwtsacpica.la
 
-libfwtsacpica_la_LDFLAGS = -lpthread -version-info 1:0:0
+libfwtsacpica_la_LDFLAGS = -version-info 1:0:0
+libfwtsacpica_la_LIBADD = -lpthread
 libfwtsacpica_la_CPPFLAGS = $(AM_CPPFLAGS)
 
 #
@@ -280,8 +281,4 @@  libfwtsacpica_la_SOURCES =						\
 	../../src/acpica/source/tools/acpiexec/aeinstall.c		\
 	../../src/acpica/source/os_specific/service_layers/osgendbg.c
 
-libfwtsacpica_la_LIBADD = \
-	-L../../src/lib/src -lfwts -lrt
-
-
 -include ../../git.mk
diff --git a/src/libfwtsiasl/Makefile.am b/src/libfwtsiasl/Makefile.am
index 328134c..2728780 100644
--- a/src/libfwtsiasl/Makefile.am
+++ b/src/libfwtsiasl/Makefile.am
@@ -104,8 +104,8 @@  BUILT_SOURCES = aslcompiler.y		\
 #
 # Just export fwts specific API so we don't clash with core ACPICA library
 #
-libfwtsiasl_la_LDFLAGS = -export-symbols-regex "fwts_.*" -lpthread -version-info 1:0:0
-
+libfwtsiasl_la_LDFLAGS = -export-symbols-regex "fwts_.*" -version-info 1:0:0
+libfwtsiasl_la_LIBADD = -lpthread
 CLEANFILES = $(BUILT_SOURCES)
 
 libfwtsiasl_la_CPPFLAGS = $(AM_CPPFLAGS)
-- 
2.35.1