Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 331527 - Include autoconf example of -Wl,--as-needed check in asneeded guide (to have reference for upstreams)
Summary: Include autoconf example of -Wl,--as-needed check in asneeded guide (to have ...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Quality Assurance Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-07 14:35 UTC by Samuli Suominen (RETIRED)
Modified: 2011-03-07 08:56 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
autoconf+asneeded_check.example (autoconf+asneeded_for_upstream.example,509 bytes, text/plain)
2010-08-07 14:36 UTC, Samuli Suominen (RETIRED)
Details
as-needed-am_ldflags.example (as-needed-am_ldflags.example,370 bytes, text/plain)
2010-08-14 10:44 UTC, Fab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samuli Suominen (RETIRED) gentoo-dev 2010-08-07 14:35:42 UTC
Please check if the syntax looks proper to you, the code is somwhat directly from Xfce4 packages and has tested to be working on nearly all arch's, including Prefix ones.

But please check if quoting is proper etc.
Comment 1 Samuli Suominen (RETIRED) gentoo-dev 2010-08-07 14:36:24 UTC
Created attachment 241779 [details]
autoconf+asneeded_check.example
Comment 2 Samuli Suominen (RETIRED) gentoo-dev 2010-08-09 21:47:29 UTC
Comment on attachment 241779 [details]
autoconf+asneeded_check.example

While the above code is working pretty good -- Mike pointed me out to an already existing autoconf macro for checking if LDFLAGS works:

http://www.gnu.org/software/autoconf-archive/ax_check_linker_flags.html

should make use of that instead.
Comment 3 Markos Chandras (RETIRED) gentoo-dev 2010-08-13 19:37:19 UTC
Yeah the code on the pasted link looks good. Errr, where do you want this autoconf example to go? devmanual?
Comment 4 Samuli Suominen (RETIRED) gentoo-dev 2010-08-13 19:58:49 UTC
to xml/htdocs/proj/en/qa/asneeded.xml, i'll attach a patch here against the .xml soon...
Comment 5 Fab 2010-08-14 10:44:26 UTC
Created attachment 242925 [details]
as-needed-am_ldflags.example


If you want to strictly apply the theory, you should not (re)define an
user variable such as LDFLAGS into your configure.ac (or Makefile.am) :
developers should use AM_LDFLAGS to define common linker flags and
foo_LDFLAGS to define linker flags for the specific target foo.

The attached code example works fine (tested in the build system from my own package). It allows the user to define the LDFLAGS variable in last resort on make command line without making disappear the --as-needed definition.


http://www.gnu.org/software/autoconf/manual/autoconf.html#Preset-Output-Variables
>
> Sometimes package developers are tempted to set user variables such
> as CFLAGS because it appears to make their job easier. However, the
> package itself should never set a user variable, particularly not to
> include switches that are required for proper compilation of the package.
>   [...]
> If the package developer needs to add switches without interfering with
> the user, the proper way to do that is to introduce an additional
> variable. Automake makes this easy by introducing AM_CFLAGS (see Flag
> Variables Ordering), but the concept is the same even if Automake is not used.
>

http://www.gnu.org/software/autoconf/manual/automake.html#Flag-Variables-Ordering
>
> The reason ‘$(CPPFLAGS)’ appears after ‘$(AM_CPPFLAGS)’ or ‘$(mumble_CPPFLAGS)’
> in the compile command is that *users should always have the last say*.
>
>	[...]
>
> You should never redefine a user variable such as CPPFLAGS in Makefile.am.
> Use ‘automake -Woverride’ to diagnose such mistakes. Even something like
>
>     CPPFLAGS = -DDATADIR=\"$(datadir)\" @CPPFLAGS@
>
> is erroneous. Although this preserves configure's value of CPPFLAGS, the
> definition of DATADIR will disappear if a user attempts to override CPPFLAGS
> from the make command line.
>
>     AM_CPPFLAGS = -DDATADIR=\"$(datadir)\"
>
> is all that is needed here if no per-target flags are used.
>
> You should not add options to these user variables within configure either,
> for the same reason.
>
Comment 6 SpanKY gentoo-dev 2010-08-14 17:41:01 UTC
your example has spurious whitespace all over

further, you should be appending AM_LDFLAGS, not clobbering it.  use AS_VAR_APPEND().