Subject: pkg/25249: editors/xemacs won't compile on FreeBSD 5.2.1, fix attached
To: None <>
From: None <>
List: pkgsrc-bugs
Date: 04/20/2004 00:01:49
>Number:         25249
>Category:       pkg
>Synopsis:       editors/xemacs won't compile on FreeBSD 5.2.1, fix attached
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 20 00:02:00 UTC 2004
>Originator:     Michal Pasternak
>Release:        N/A
Good People With Bad Reputation
FreeBSD 5.2.1-RC FreeBSD 5.2.1-RC #0: Sat Jan 31 05:36:22 GMT 2004  i386

Well, I've promised myself not to send any more PRs. Seems I've changed
my mind. Please be so kind then and don't let this one wait too long.

editors/xemacs build on FreeBSD 5.2.1-RC will break at configure phase:
checking size of short... 0

*** PANIC *** Configure tests are not working - compiler is broken.
*** PANIC *** Please examine config.log for compilation errors.
*** Error code 1

bmake: stopped in /usr/pkgsrc/editors/xemacs
*** Error code 1

... while config.log contains:
configure:4513: checking size of short
configure:4527: gcc -o conftest -pipe -Dunix -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/
freetype2 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2  -I/usr/obj/pkgsrc/editor
s/xemacs/work.j1/.buildlink/include -I/usr/obj/pkgsrc/editors/xemacs/work.j1      -Xlinker -pthrea
d -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/X11R6/lib -Wl,-R/usr/pkg/
X11R6/lib  -Xlinker -z -Xlinker nocombreloc -L/usr/obj/pkgsrc/editors/xemacs/work.j1/.buildlink/li
b     conftest.c         -lutil -lxpg4 -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o 1>&5
/usr/bin/ld: unrecognized option '-pthread'
/usr/bin/ld: use the --help option for usage information
configure: failed program was:
#line 4516 "configure"
#include "confdefs.h"
#include <stdio.h>
  FILE *f=fopen("conftestval", "w");
  if (!f) exit(1);
  fprintf(f, "%d\n", sizeof(short));

The configure script in many places uses such construct:
if test "$GCC" = "yes"; then
  set x $ld_switch_machine; shift; ld_switch_machine=""
  while test -n "$1"; do
    case $1 in
      -L  | -l  | -u               ) ld_switch_machine="$ld_switch_machine $1 $2"; shift ;;
      -L* | -l* | -u* | -Wl* | -pg ) ld_switch_machine="$ld_switch_machine $1" ;;
      -Xlinker* ) ;;
      * ) ld_switch_machine="$ld_switch_machine -Xlinker $1" ;;

As you can clearly see, "-pthread" will match *) rule, and will
be appended as an option for ld (after -Xlinker). 

On FreeBSD this is very wrong.

So then, we patch the script so it includes "-pthread" _before_
-Xlinker, just as it would do with -l*, -pg and such:

    ... -pg | -pthread ) ...

Perhaps the same patch applies for xemacs-current, but I haven't
checked. I've described the method clearly enough, so you should
get it.

Patch is at:

Have fun!