Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Nov 1999 14:25:30 +0100
From:      Marcel Moolenaar <marcel@scc.nl>
To:        freebsd-arch@freebsd.org
Subject:   Cross-building (was: cross compilation goals)
Message-ID:  <383A95CA.AC00E8B@scc.nl>

next in thread | raw e-mail | index | archive | help
[the patches in this posting are for illustration purposes only. They
once worked, but have been lying around for too long to be safely used
as is. Also, spacing may be corrupted due to cut-n-paste and
line-breaking]

To continue where we left off I want to discuss some changes to gcc. To
make sure nobody gets the wrong impression: The changes are only to the
FreeBSD specific additions or modifications!

The reason for these changes are:
o  Remove old code that has lost its function,
o  Introduce more (compile time) flexibility,
o  Bug fixes.

Index:
1. Remove support for /etc/objformat
2. Make hardcoded paths PREFIX related

Your comments?

1. Remove support for /etc/objformat
------------------------------------

The reasons for this change are:
o  /etc/objformat does not exist anymore,
o  It interferes with cross-compilation.

The last bullet is explained by the following situation: Assume we want
to (source) upgrade from 3.0-RELEASE to -current. The machine has
/etc/objformat which contains OBJFORMAT=aout...

The functionality lost by this removal is nicely covered by the ability
to specify OBJFORMAT in the environment.

patch:

Index: contrib/egcs/gcc/gcc.c
===================================================================
RCS file: /home/ncvs/src/contrib/egcs/gcc/gcc.c,v
retrieving revision 1.4
diff -u -r1.4 gcc.c
--- gcc.c       1999/09/13 15:41:42     1.4
+++ gcc.c       1999/11/03 17:07:53
@@ -2718,26 +2718,7 @@
     }
 
 #if defined(FREEBSD_NATIVE) && defined(__i386__)
-  {
-    /* first hint is /etc/objformat */
-    FILE *fp = fopen("/etc/objformat", "r");
-    if (fp) {
-      char buf[1024];
-      buf[1023] = '\0';
-      while (fgets(buf, sizeof(buf) - 1, fp) != NULL) {
-       i = strlen(buf);
-       if (buf[i - 1] == '\n')
-         buf[i - 1] = '\0';
-       if (strcmp(buf, "OBJFORMAT=aout") == 0)
-         objformat_aout = 1;
-       else if (strcmp(buf, "OBJFORMAT=elf") == 0)
-         objformat_aout = 0;
-       else
-         fprintf(stderr, "Unrecognized line in /etc/objformat: %s\n",
buf);
-      }
-      fclose(fp);
-    }
-    /* but the user $OBJFORMAT overrides system default */
+    /* the user $OBJFORMAT overrides system default */
     temp = getenv("OBJFORMAT");
     if (temp) {
       if (strcmp(temp, "aout") == 0)
@@ -2747,7 +2728,6 @@
       else
        fprintf(stderr, "Unrecognized value of $OBJFORMAT: %s\n", temp);
     }
-  }
 #endif

2. Make hardcoded paths PREFIX related
--------------------------------------

The reasons for this change are:
o  The ability to "rebase" the compiler toolset,
o  To simplify cross-compilation.

All FreeBSD specific paths are hardcoded in gcc itself. Instead of
having "/usr/libexec/elf/" in gcc I suggest something like
PREFIX"/libexec/elf/". This allows for compile-time control over where
gcc should look for backend tools. This simplifies a cross-world,
because the compiler that's build during tool-building can be based in
the object tree and can be used without any special treatment other than
setting the PATH to point to the cross-compiler.

The idea was taken from cc/cc_drv/Makefile where the same thing happens.
I just applied it to gcc at large.

The patch also contains some bug fixes.
For example:
	-  add_prefix (&exec_prefixes, "/usr/libexec", "GCC",
	+  add_prefix (&exec_prefixes, PREFIX"/libexec/", "GCC",
or
	-  add_prefix (&exec_prefixes, "/usr/bin", "GCC",
	+  add_prefix (&exec_prefixes, PREFIX"/bin/", "GCC",

"exec_prefixes" *must* be terminated by slashes to be effective. The
reason why it did work was because we had a second "/usr/libexec/" with
the terminating slash as can be seen with:

scones% gcc --print-search-dirs
install: /usr/libexec/(null)
programs: /usr/libexec/elf/:/usr/libexec:/usr/bin:/usr/libexec/
libraries: /usr/libdata/gcc/:/usr/libexec/:/usr/ccs/lib/:/usr/lib/

patch:

Index: contrib/egcs/gcc/gcc.c
===================================================================
RCS file: /home/ncvs/src/contrib/egcs/gcc/gcc.c,v
retrieving revision 1.4
diff -u -r1.4 gcc.c
--- gcc.c       1999/09/13 15:41:42     1.4
+++ gcc.c       1999/11/03 17:07:53
@@ -3104,17 +3084,17 @@
 #if defined(__i386__)
   if (objformat_aout) {
     n_switches++;              /* add implied -maout */
-    add_prefix (&exec_prefixes, "/usr/libexec/aout/", "BINUTILS",
+    add_prefix (&exec_prefixes, PREFIX"/libexec/aout/", "BINUTILS",
              0, 0, NULL_PTR);
   } else
-    add_prefix (&exec_prefixes, "/usr/libexec/elf/", "BINUTILS",
+    add_prefix (&exec_prefixes, PREFIX"/libexec/elf/", "BINUTILS",
              0, 0, NULL_PTR);
 #endif
-  add_prefix (&exec_prefixes, "/usr/libexec", "GCC",
+  add_prefix (&exec_prefixes, PREFIX"/libexec/", "GCC",
              0, 0, warn_std_ptr);
-  add_prefix (&exec_prefixes, "/usr/bin", "GCC",
+  add_prefix (&exec_prefixes, PREFIX"/bin/", "GCC",
              0, 0, warn_std_ptr);
-  add_prefix (&startfile_prefixes, "/usr/libdata/gcc/", "BINUTILS",
+  add_prefix (&startfile_prefixes, PREFIX"/libdata/gcc/", "BINUTILS",
              0, 0, warn_std_ptr);
 #else /* not FREEBSD_NATIVE */
 #ifndef OS2
Index: gnu/usr.bin/cc/Makefile.inc
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/Makefile.inc,v
retrieving revision 1.39
diff -u -r1.39 Makefile.inc
--- Makefile.inc        1999/10/12 20:22:38     1.39
+++ Makefile.inc        1999/11/03 11:12:42
@@ -29,16 +29,16 @@
 CFLAGS+=       -DFREEBSD_NATIVE -DHAVE_CONFIG_H
 CFLAGS+=       -DDEFAULT_TARGET_VERSION=\"$(version)\"
 CFLAGS+=       -DDEFAULT_TARGET_MACHINE=\"$(target)\"
+CFLAGS+=       -DPREFIX=\"${DESTDIR}/usr\"
 
 .if defined(USE_EGCS_HAIFA)
 CFLAGS+=       -DHAIFA
Index: gnu/usr.bin/cc/cc_drv/Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc_drv/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile    1999/08/27 23:35:15     1.4
+++ Makefile    1999/11/03 11:13:02
@@ -6,7 +6,6 @@
 
 SRCS=  multilib.h choose-temp.c obstack.c prefix.c pexecute.c version.c
 
-CFLAGS+=       -DPREFIX=\"/usr\"
 CFLAGS+=       -DIN_GCC
 
 LIB=           cc_drv
Index: gnu/usr.bin/cc/cc_tools/freebsd-native.h
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc_tools/freebsd-native.h,v
retrieving revision 1.3
diff -u -r1.3 freebsd-native.h
--- freebsd-native.h    1999/08/27 23:35:17     1.3
+++ freebsd-native.h    1999/11/03 16:56:58
@@ -6,8 +6,8 @@
 
 /* Look for the include files in the system-defined places.  */
 
-#define GPLUSPLUS_INCLUDE_DIR          "/usr/include/g++"
-#define GCC_INCLUDE_DIR                        "/usr/include"
+#define GPLUSPLUS_INCLUDE_DIR          PREFIX"/include/g++"
+#define GCC_INCLUDE_DIR                        PREFIX"/include"
 
 /* Now that GCC knows what the include path applies to, put the G++ one
first.
    C++ can now have include files that override the default C ones.  */
@@ -26,15 +26,15 @@
 #undef TOOLDIR_BASE_PREFIX
 #undef MD_EXEC_PREFIX
 
-#define STANDARD_EXEC_PREFIX           "/usr/libexec/"
-#define TOOLDIR_BASE_PREFIX            "/usr/libexec/"
-#define MD_EXEC_PREFIX                 "/usr/libexec/"
+#define STANDARD_EXEC_PREFIX           PREFIX"/libexec/"
+#define TOOLDIR_BASE_PREFIX            PREFIX"/libexec/"
+#define MD_EXEC_PREFIX                 PREFIX"/libexec/"
 
 /* Under FreeBSD, the normal location of the various *crt*.o files is
the
    /usr/lib directory.  */
 
 #undef STANDARD_STARTFILE_PREFIX
-#define STANDARD_STARTFILE_PREFIX      "/usr/lib/"
+#define STANDARD_STARTFILE_PREFIX      PREFIX"/lib/"
 
 /* FreeBSD is 4.4BSD derived */
 #define bsd4_4

-- 
Marcel Moolenaar                        mailto:marcel@scc.nl
SCC Internetworking & Databases           http://www.scc.nl/
The FreeBSD project                mailto:marcel@FreeBSD.org




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?383A95CA.AC00E8B>