tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Cross Compile NetBSD on OpenBSD
Hi,
With these tiny changes I am able to build the NetBSD toolchain on
OpenBSD. Both are i386, I have not tested other architectures.
Kernel compiles and runs, I have not tried userland yet.
Comments to each issue are inlined within diff. I am not sure if
you want this in your tree.
bluhm
OpenBSD's uname -p is not compatible to NetBSD, e.g. it gives this
string and the () confuse build.sh.
Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz ("GenuineIntel" 686-class)
Index: build.sh
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/build.sh,v
retrieving revision 1.200
diff -u -p -r1.200 build.sh
--- build.sh 3 Jan 2009 08:23:00 -0000 1.200
+++ build.sh 31 Jan 2009 00:06:25 -0000
@@ -170,7 +170,7 @@ initdefaults()
uname_s=$(uname -s 2>/dev/null)
uname_r=$(uname -r 2>/dev/null)
uname_m=$(uname -m 2>/dev/null)
- uname_p=$(uname -p 2>/dev/null || uname -m 2>/dev/null)
+ uname_p=$(uname -m 2>/dev/null)
# If $PWD is a valid name of the current directory, POSIX mandates
# that pwd return it by default which causes problems in the
Your texinfo/info/echo-area.c uses intptr_t, on OpenBSD you have
to include stdint.h for that.
Index: gnu/dist/texinfo/lib/system.h
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/gnu/dist/texinfo/lib/system.h,v
retrieving revision 1.10
diff -u -p -r1.10 system.h
--- gnu/dist/texinfo/lib/system.h 9 Sep 2008 06:32:59 -0000 1.10
+++ gnu/dist/texinfo/lib/system.h 30 Jan 2009 21:20:15 -0000
@@ -269,6 +269,10 @@ extern int strcoll ();
/* Some systems don't declare this function in pwd.h. */
struct passwd *getpwnam (const char *name);
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* Our library routines not included in any system library. */
extern void *xmalloc (size_t), *xrealloc (void *, size_t);
extern char *xstrdup (const char *);
The WA() defines seem to be a little different. The additional ;
should not hurt anybody.
Index: lib/libc/hash/hashhl.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/lib/libc/hash/hashhl.c,v
retrieving revision 1.1
diff -u -p -r1.1 hashhl.c
--- lib/libc/hash/hashhl.c 28 Sep 2005 16:31:45 -0000 1.1
+++ lib/libc/hash/hashhl.c 30 Jan 2009 20:58:39 -0000
@@ -32,10 +32,10 @@
#if !defined(_KERNEL) && defined(__weak_alias)
#define WA(a,b) __weak_alias(a,b)
-WA(FNPREFIX(End),CONCAT(_,FNPREFIX(End)))
-WA(FNPREFIX(FileChunk),CONCAT(_,FNPREFIX(FileChunk)))
-WA(FNPREFIX(File),CONCAT(_,FNPREFIX(File)))
-WA(FNPREFIX(Data),CONCAT(_,FNPREFIX(Data)))
+WA(FNPREFIX(End),CONCAT(_,FNPREFIX(End)));
+WA(FNPREFIX(FileChunk),CONCAT(_,FNPREFIX(FileChunk)));
+WA(FNPREFIX(File),CONCAT(_,FNPREFIX(File)));
+WA(FNPREFIX(Data),CONCAT(_,FNPREFIX(Data)));
#undef WA
#endif
Index: lib/libc/md/mdXhl.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/lib/libc/md/mdXhl.c,v
retrieving revision 1.7
diff -u -p -r1.7 mdXhl.c
--- lib/libc/md/mdXhl.c 26 Sep 2005 03:01:41 -0000 1.7
+++ lib/libc/md/mdXhl.c 30 Jan 2009 21:00:21 -0000
@@ -20,9 +20,9 @@
#if !defined(_KERNEL) && defined(__weak_alias)
#define WA(a,b) __weak_alias(a,b)
-WA(MDNAME(End),CONCAT(_,MDNAME(End)))
-WA(MDNAME(File),CONCAT(_,MDNAME(File)))
-WA(MDNAME(Data),CONCAT(_,MDNAME(Data)))
+WA(MDNAME(End),CONCAT(_,MDNAME(End)));
+WA(MDNAME(File),CONCAT(_,MDNAME(File)));
+WA(MDNAME(Data),CONCAT(_,MDNAME(Data)));
#undef WA
#endif
The uname -p issue again. Don't know how to fix this in a compatible
way. Perhaps you ask the GNU autoconf people :-)
Index: share/mk/bsd.own.mk
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/share/mk/bsd.own.mk,v
retrieving revision 1.553
diff -u -p -r1.553 bsd.own.mk
--- share/mk/bsd.own.mk 30 Dec 2008 21:31:10 -0000 1.553
+++ share/mk/bsd.own.mk 30 Jan 2009 23:50:42 -0000
@@ -125,7 +125,7 @@ USETOOLS?= no
.if !defined(HOST_OSTYPE)
_HOST_OSNAME!= uname -s
_HOST_OSREL!= uname -r
-_HOST_ARCH!= uname -p 2>/dev/null || uname -m
+_HOST_ARCH!= uname -m
HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/
/_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g}
.MAKEOVERRIDES+= HOST_OSTYPE
.endif
The OpenBSD linker prints warnings whenever strcpy() is used as it
is considered insecure. These warnings confuse build.sh. So I
replaced strcpy() with strncpy() although it cannot be exploited
in this case.
Index: usr.bin/make/dir.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/usr.bin/make/dir.c,v
retrieving revision 1.61
diff -u -p -r1.61 dir.c
--- usr.bin/make/dir.c 24 Jan 2009 10:59:09 -0000 1.61
+++ usr.bin/make/dir.c 30 Jan 2009 17:21:03 -0000
@@ -642,7 +642,7 @@ DirExpandCurly(const char *word, const c
if (cp != start) {
strncpy(&file[brace-word], start, cp-start);
}
- strcpy(&file[(brace-word)+(cp-start)], end);
+ strncpy(&file[(brace-word)+(cp-start)], end, otherLen-(brace-word)+1);
/*
* See if the result has any wildcards in it. If we find one, call
Index: usr.bin/make/hash.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/usr.bin/make/hash.c,v
retrieving revision 1.19
diff -u -p -r1.19 hash.c
--- usr.bin/make/hash.c 24 Jan 2009 10:59:09 -0000 1.19
+++ usr.bin/make/hash.c 31 Jan 2009 00:05:18 -0000
@@ -293,7 +293,7 @@ Hash_CreateEntry(Hash_Table *t, const ch
*hp = e;
Hash_SetValue(e, NULL);
e->namehash = h;
- (void)strcpy(e->name, p);
+ (void)strncpy(e->name, p, keylen + 1);
t->numEntries++;
if (newPtr != NULL)
Index: usr.bin/make/job.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/usr.bin/make/job.c,v
retrieving revision 1.144
diff -u -p -r1.144 job.c
--- usr.bin/make/job.c 23 Jan 2009 21:26:30 -0000 1.144
+++ usr.bin/make/job.c 30 Jan 2009 16:41:10 -0000
@@ -1553,7 +1553,7 @@ JobStart(GNode *gn, int flags)
}
JobSigLock(&mask);
- (void)strcpy(tfile, TMPPAT);
+ (void)strncpy(tfile, TMPPAT, sizeof(tfile));
if ((tfd = mkstemp(tfile)) == -1)
Punt("Could not create temporary file %s", strerror(errno));
if (!DEBUG(SCRIPT))
OpenBSD include files define swap..() as a macro. This collides
with the inline functions.
Index: usr.sbin/pwd_mkdb/pwd_mkdb.c
===================================================================
RCS file: /data/mirror/netbsd/cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.36
diff -u -p -r1.36 pwd_mkdb.c
--- usr.sbin/pwd_mkdb/pwd_mkdb.c 16 Jan 2009 10:42:36 -0000 1.36
+++ usr.sbin/pwd_mkdb/pwd_mkdb.c 30 Jan 2009 21:51:50 -0000
@@ -168,12 +168,18 @@ void checkversion(DB *);
uint32_t getversion(void);
void setversion(DB *);
+#ifdef swap16
+#undef swap16
+#endif
static __inline uint16_t swap16(uint16_t sw)
{
return ((sw & 0x00ff) << 8) |
((sw & 0xff00) >> 8);
}
+#ifdef swap32
+#undef swap32
+#endif
static __inline uint32_t swap32(uint32_t sw) {
return ((sw & 0x000000ff) << 24) |
((sw & 0x0000ff00) << 8) |
@@ -181,6 +187,9 @@ static __inline uint32_t swap32(uint32_t
((sw & 0xff000000) >> 24);
}
+#ifdef swap64
+#undef swap64
+#endif
static __inline uint64_t swap64(uint64_t sw) {
return ((sw & 0x00000000000000ffULL) << 56) |
((sw & 0x000000000000ff00ULL) << 40) |
Home |
Main Index |
Thread Index |
Old Index