Subject: port-i386/9374: egcs broken, won't handle Objective-C code
To: None <gnats-bugs@gnats.netbsd.org>
From: Jeroen Scheerder <J.Scheerder@cwi.nl>
List: netbsd-bugs
Date: 02/08/2000 07:57:53
>Number:         9374
>Category:       port-i386
>Synopsis:       egcs broken, won't handle Objective-C code
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer (NetBSD/i386 Portmaster)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb  8 07:57:00 2000
>Last-Modified:
>Originator:     Jeroen Scheerder
>Organization:
>Release:        NetBSD 1.4.1
>Environment:
System: NetBSD dek 1.4.1 NetBSD 1.4.1 (JS) #1: Fri Sep 17 12:56:09 MEST 1999 js@dek:/usr/src/sys/arch/i386/compile/JS i386


>Description:

Trying to get GNUstep to work, I find that the egcs port is broken where
running Objective-C code is concerned.  I first noticed this on the existing
egcs-1.1.1; I updated that to the current version, 1.1.2.  The problem
persisted, though.

>How-To-Repeat:

Consider the following snippet:

  js:p4@dek[410]> cat hello.m                             /extra/js/samples 16:46
  #import <objc/Object.h>

  int main(int argc, char **argv) {
          id myObject;

          myObject = [Object new];

          printf("hello world\n");
          return 0;
  }

Now this should run, trivially.

  js:p4@dek[411]> gcc -Wno-import -o hello hello.m -lobjc
  ld: /tmp/ccaHCHDw.o: RRS text relocation at 0x184c for "___objc_class_name_Object"
  js:p4@dek[412]> ./hello                                 /extra/js/samples 16:46
  objc runtime: cannot find class Object
  zsh: abort (core dumped)  ./hello

>Fix:

As a workaround, supplying th `-static' switch seems to alleviate the problems:

  js:p4@dek[413]> gcc -Wno-import -static -o hello hello.m -lobjc
  js:p4@dek[414]> ./hello                                 /extra/js/samples 16:46
  hello world

Adding the `-static' switch didn't help GNUstep compilation, though;
the ld errors about RSS text relocation, and the core dumps caused by
the runtime environment's unability to bind the Object class appear
there even when linking statically.
>Audit-Trail:
>Unformatted: