You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Todd Vierling <tv...@pobox.com> on 1999/12/05 18:31:06 UTC

mod_so/5421: apxs fails due to unparsed -Wl arguments

>Number:         5421
>Category:       mod_so
>Synopsis:       apxs fails due to unparsed -Wl arguments
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Sun Dec  5 09:40:00 PST 1999
>Last-Modified:
>Originator:     tv@pobox.com
>Organization:
apache
>Release:        1.3.9
>Environment:
NetBSD, all versions, all gcc-derived compilers
>Description:
As stated (probably not completely enough) in PR #4294, apxs is failing on some
OS's because it is not parsing arguments correctly.

apxs uses an extension of perl's "Getopts" routine to parse command line
arguments.  Around line 380, apxs tries to reformat -Wl options for the linker,
if it is not "gcc" (which IMHO may not be appropriate either; shouldn't it
check to see if it equals $CFG_CC _and_ $CFG_CC is a gcc-derived compiler?).

The "foreach" here:

    foreach $opt_Wl (@opt_W) {
                if($CFG_LD_SHLIB ne "gcc") {
                $opt .= " $1" if ($opt_Wl =~ m|^\s*l,(.*)$|);    
                } else {
                $opt .= " -W$opt_Wl";
                }
    }

is never executed, because "Getopts" stops parsing on the first command line
argument not beginning with a dash (-).  However, -L, -l, and -Wl options are
typically placed at the _end_ of the command line, after the object file names.

Insert a "print STDERR $cmd" debug line just before the "foreach" and this
problem should be quite obvious.
>How-To-Repeat:
Run on an OS such as NetBSD, or temporarily change CFG_LD_SHLIB to something
different from "gcc" ("echo" will suffice).  Then add a random -Wl,-foo option
after non-dash arguments and note that it isn't transformed into -foo.
>Fix:
Fix the included "Getopts" to parse options specified after non-option
arguments.  Remember, too, that many compilers accept options specified
at random places on the command line.
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, you need]
[to include <ap...@Apache.Org> in the Cc line and make sure the]
[subject line starts with the report component and number, with ]
[or without any 'Re:' prefixes (such as "general/1098:" or      ]
["Re: general/1098:").  If the subject doesn't match this       ]
[pattern, your message will be misfiled and ignored.  The       ]
["apbugs" address is not added to the Cc line of messages from  ]
[the database automatically because of the potential for mail   ]
[loops.  If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request from a  ]
[developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]