Problems building caml-stubdom
Hi all,
I am trying to build the ocaml stub domain and I am having some compilation issues. I am getting a bunch of undefined references when linking mini-os.o.
ld -nostdlib -L/research/geoffrey/xen/xen-unstable.hg/stubdom/cross-root-i686/i686-xen-elf/lib
-m elf_i386 -T arch/x86/minios-x86_32.lds
/research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o
-o /research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os /research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_sys_file_exists':
ungetc.c:(.text+0x14e0d): undefined reference to `__xstat' /research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_executable_name':
ungetc.c:(.text+0x18ac9): undefined reference to `__xstat' /research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_search_in_path':
ungetc.c:(.text+0x18d2f): undefined reference to `__xstat'
make[1]: *** [/research/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os] Error 1
make[1]: Leaving directory `/research/geoffrey/xen/xen-unstable.hg/extras/mini-os'
I have managed to get rid of other linking errors by building ocaml with -fno-stack-protector and without large file support but I am still having the linking issue above. I think i need to build the ocaml runtime against newlib but how does one do that?
thanks,
geoffrey
Quoted 3 lines · Geoffrey Lefebvre, le Wed 06 Aug 2008 15:33:42 -0700, a écrit :
I am trying to build the ocaml stub domain and I am having some compilation issues. I am getting a bunch of undefined references when linking mini-os.o.
Ah.
Quoted 3 lines
I have managed to get rid of other linking errors by building ocaml with -fno-stack-protector and without large file support but I am still having the linking issue above.
Ok. I had just tested with the debian-provided caml binaries.
Quoted 1 line
I think i need to build the ocaml runtime against newlib
I guess that's the long run way yes.
Quoted 1 line
but how does one do that?
It's not only against newlib, but also against Mini-OS headers. That's a TODO for now.
Samuel
Quoted 1 line
Ok. I had just tested with the debian-provided caml binaries.
I was originally using the ubuntu 8.04 ocaml binaries and I also tried using the ocaml 3.09 tar ball from inria.
Following your advice, I tried building the caml stubdomain using debian 4.0. The version of ocaml is 3.09.2. I get undefined reference to open64 and lseek64. Which version of debian and ocaml did you use to build the stub domain?
ld -nostdlib -L/nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/cross-root-i686/i686-xen-elf/lib
-m elf_i386 -T arch/x86/minios-x86_32.lds
/nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o
-o /nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os
/nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_seek_in':
gdtoa-hexnan.c:(.text+0x11cb4): undefined reference to `lseek64' /nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_channel_size':
gdtoa-hexnan.c:(.text+0x11e17): undefined reference to lseek64' gdtoa-hexnan.c:(.text+0x11e42): undefined reference to lseek64' /nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_seek_out':
gdtoa-hexnan.c:(.text+0x12a1f): undefined reference to `lseek64' /nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_open_descriptor_in':
gdtoa-hexnan.c:(.text+0x12b80): undefined reference to `lseek64' /nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os.o:
In function `caml_sys_open':
gdtoa-hexnan.c:(.text+0x15248): undefined reference to `open64'
make[1]: *** [/nfs/ceuse/geoffrey/xen/xen-unstable.hg/stubdom/mini-os-caml/mini-os] Error 1
thanks,
geoffrey
Quoted 4 lines · Geoffrey Lefebvre, le Wed 06 Aug 2008 23:56:21 -0700, a écrit :
Quoted 1 line
Ok. I had just tested with the debian-provided caml binaries.
I was originally using the ubuntu 8.04 ocaml binaries and I also tried using the ocaml 3.09 tar ball from inria.
The source code itself probably doesn't matter so much, it's actually rather the configuration and glibc it's linking with that matters.
Quoted 3 lines
Following your advice, I tried building the caml stubdomain using debian 4.0. The version of ocaml is 3.09.2. I get undefined reference to open64 and lseek64.
I guess you have a 32bit machine? I don't think I have tried that. The problem here is that the caml binary uses the linux ABI. I don't think we want to support that ad aeternam. I hoped that for (very) basic use we wouldn't have to recompile caml. I guess I can easily just add them, I'll see.
Quoted 2 lines
Which version of debian and ocaml did you use to build the stub domain?
debian 3.10.2-3.
Samuel
PATCH 1/1 caml-stubdom: turn off_t 64bit on x86 [Was: Problems building caml-stubdom]
In reply to Geoffrey Lefebvrestubdom: turn off_t 64bit on x86
We can decide to make off_t 64bit instead of implementing the LFS tricks. Name corresponding functions foo64 to permit simple caml programs linking.
extras/mini-os/include/fcntl.h +3 -2
@@ -91,8 +91,9 @@ struct flock64 {#define F_LINUX_SPECIFIC_BASE 1024 */ -int open (const char *path,int flags, ...); -int fcntl (int fd,int cmd, ...);#endif +int open (const char *path,int flags, ...) asm("open64" ); +int fcntl (int fd,int cmd, ...); +#endif
extras/mini-os/include/posix/sys/mman.h +1 -1
@@ -14,7 +14,7 @@#define MAP_FAILED ((void*)0) -void *mmap (void *start,size_t length,int prot,int flags,int fd,off_t offset); +void *mmap (void *start,size_t length,int prot,int flags,int fd,off_t offset) asm("mmap64" );int munmap (void *start,size_t length);#define munlock (addr, len) ((void)addr, (void)len, 0)#define mlock (addr, len) ((void)addr, (void)len, 0)
extras/mini-os/include/posix/sys/stat.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef _POSIX_SYS_STAT_H +#define _POSIX_SYS_STAT_H + +#include_next <sys/stat.h> +int fstat (int fd,struct stat *buf) asm("fstat64" ); + +#endif /* _POSIX_SYS_STAT_H */
extras/mini-os/lib/sys.c +0 -9
@@ -204,9 +204,6 @@ int open(const char *pathname, int flags files[fd].file.offset =0 ;return fd; } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(open) open64 __attribute__((__alias__("open"))); -#endif int isatty (int fd) {
@@ -347,9 +344,6 @@ off_t lseek(int fd, off_t offset, int wh }return files[fd].file.offset; } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(lseek) lseek64 __attribute__((__alias__("lseek"))); -#endif int fsync (int fd) {switch (files[fd].type) {
@@ -1184,9 +1178,6 @@ void *mmap(void *start, size_t length, ireturn map_frames_ex (&zero, n,0 ,0 ,1 ,DOMID_SELF ,0 ,0 ); }else ASSERT (0 ); } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(mmap) mmap64 __attribute__((__alias__("mmap"))); -#endif int munmap (void *start,size_t length) {
stubdom/newlib.patch +120 -0
123 lines not on this page · raw message
Re: [PATCH] caml-stubdom: turn off_t 64bit on x86 [Was: Problems building caml-stubdom]
Hi,
To answer your question on your previous email, I am running a 32 bit xen. Thanks for the patch. I can now build the caml stubdom on 32 bit debian 4.0 and run the mini-os caml domain.
geoffrey
Quoted 207 lines · Samuel Thibault
stubdom: turn
off_t64bit on x86We can decide to make
off_t64bit instead of implementing the LFS tricks. Name corresponding functions foo64 to permit simple caml programs linking.Signed-off-by Samuel Thibault <[email protected]>diff -r
c43e01d53d1dextras/mini-os/include/fcntl.hextras/mini-os/include/fcntl.h Thu Aug 07 18:21:37 2008 +0100 renamed from extras/mini-os/include/fcntl.h Wed Aug 06 11:54:09 2008 +0100 +3
-2@@ -91,8 +91,9 @@ struct flock64 { #define F_LINUX_SPECIFIC_BASE 1024 */ -int open(const char *path, int flags, ...); -int fcntl(int fd, int cmd, ...); #endif +int open(const char *path, int flags, ...) asm("open64"); +int fcntl(int fd, int cmd, ...); + #endifdiff -r
c43e01d53d1dextras/mini-os/include/posix/sys/mman.hextras/mini-os/include/posix/sys/mman.h Thu Aug 07 18:21:37 2008 +0100 renamed from extras/mini-os/include/posix/sys/mman.h Wed Aug 06 11:54:09 2008 +0100 +1
-1@@ -14,7 +14,7 @@ #define MAP_FAILED ((void*)0) -void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); +void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) asm("mmap64"); int munmap(void *start, size_t length); #define munlock(addr, len) ((void)addr, (void)len, 0) #define mlock(addr, len) ((void)addr, (void)len, 0)diff -r
c43e01d53d1dextras/mini-os/include/posix/sys/stat.hextras/mini-os/include/posix/sys/stat.h Thu Aug 07 18:21:37 2008 +0100 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +7
-0@@ -0,0 +1,7 @@ +#ifndef _POSIX_SYS_STAT_H +#define _POSIX_SYS_STAT_H + +#include_next <sys/stat.h> +int fstat(int fd, struct stat *buf) asm("fstat64"); + +#endif /* _POSIX_SYS_STAT_H */diff -r
c43e01d53d1dextras/mini-os/lib/sys.cextras/mini-os/lib/sys.c Thu Aug 07 18:21:37 2008 +0100 renamed from extras/mini-os/lib/sys.c Wed Aug 06 11:54:09 2008 +0100 +0
-9@@ -204,9 +204,6 @@ int open(const char *pathname, int flags files[fd].file.offset = 0; return fd; } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(open) open64 __attribute__((__alias__("open"))); -#endif int isatty(int fd) {@@ -347,9 +344,6 @@ off_t lseek(int fd, off_t offset, int wh } return files[fd].file.offset; } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(lseek) lseek64 __attribute__((__alias__("lseek"))); -#endif int fsync(int fd) { switch (files[fd].type) {@@ -1184,9 +1178,6 @@ void *mmap(void *start, size_t length, i return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0); } else ASSERT(0); } -#if defined(__x86_64__) || defined(__ia64__) -__typeof__(mmap) mmap64 __attribute__((__alias__("mmap"))); -#endif int munmap(void *start, size_t length) {diff -r
c43e01d53d1dstubdom/newlib.patchstubdom/newlib.patch Thu Aug 07 18:21:37 2008 +0100 renamed from stubdom/newlib.patch Wed Aug 06 11:54:09 2008 +0100 +120
-0@@ -627,3 +627,123 @@ diff -u -p -r1.1 memcpy.S #ifdef _I386MACH_NEED_SOTYPE_FUNCTION #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function + + +We want to have a 64bit offsets libc even on 32bit platforms. + +--- ./newlib/configure.host.orig 2008-08-07 16:01:17.801946000 +0100 ++++ ./newlib/configure.host 2008-08-07 16:01:34.181064000 +0100 +@@ -317,6 +317,8 @@ + oext=lo + lpfx= + aext=la ;; ++ i[34567]86-xen-elf) ++ stdio64_dir=stdio64 ;; + *) ;; #shared library not supported for ${host} + esac + +--- newlib/libc/include/sys/_types.h.orig 2008-08-07 15:22:44.925008000 +0100 ++++ newlib/libc/include/sys/_types.h 2008-08-07 15:22:50.824044000 +0100 +@@ -13,8 +13,12 @@ + #include <sys/lock.h> + + #ifndef __off_t_defined ++#ifdef __MINIOS__ ++typedef long long _off_t; ++#else + typedef long _off_t; + #endif ++#endif + + #if defined(__rtems__) + /* device numbers are 32-bit major and and 32-bit minor */ +--- ./newlib/libc/include/sys/config.h.orig 2008-08-07 14:43:25.915866000 +0100 ++++ ./newlib/libc/include/sys/config.h 2008-08-07 14:44:13.508154000 +0100 +@@ -69,6 +69,10 @@ + /* we use some glibc header files so turn on glibc large file feature */ + #define _LARGEFILE64_SOURCE 1 + #endif ++#ifdef __MINIOS__ ++#define __LARGE64_FILES 1 ++#define _LARGEFILE64_SOURCE 1 ++#endif + #endif + + #ifndef __DYNAMIC_REENT__ +--- ./newlib/libc/include/sys/_default_fcntl.h.orig 2008-08-07 15:08:22.377836000 +0100 ++++ ./newlib/libc/include/sys/_default_fcntl.h 2008-08-07 15:08:31.651890000 +0100 +@@ -170,7 +170,11 @@ + /* Provide _<systemcall> prototypes for functions provided by some versions + of newlib. */ + #ifdef _COMPILING_NEWLIB +-extern int _open _PARAMS ((const char *, int, ...)); ++extern int _open _PARAMS ((const char *, int, ...)) ++#ifdef __MINIOS__ ++ asm("open64") ++#endif ++ ; + extern int _fcntl _PARAMS ((int, int, ...)); + #ifdef __LARGE64_FILES + extern int _open64 _PARAMS ((const char *, int, ...)); +--- ./newlib/libc/include/sys/unistd.h.orig 2008-08-07 15:09:36.449280000 +0100 ++++ ./newlib/libc/include/sys/unistd.h 2008-08-07 15:09:51.210370000 +0100 +@@ -101,7 +101,11 @@ + int _EXFUN(link, (const char *__path1, const char *__path2 )); + int _EXFUN(nice, (int __nice_value )); + #if !defined(__INSIDE_CYGWIN__) +-off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )); ++off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )) ++#ifdef __MINIOS__ ++ asm("lseek64") ++#endif ++ ; + #endif + #if defined(__SPU__) + #define F_ULOCK 0 +--- ./newlib/libc/include/sys/stat.h.orig 2008-08-07 16:08:50.495116000 +0100 ++++ ./newlib/libc/include/sys/stat.h 2008-08-07 16:10:21.799753000 +0100 +@@ -49,6 +49,9 @@ + long st_spare4[2]; + #endif + }; ++#ifdef __MINIOS__ ++#define stat64 stat ++#endif + #endif + + #define _IFMT 0170000 /* type of file */ +@@ -132,7 +135,11 @@ + /* Provide prototypes for most of the _<systemcall> names that are + provided in newlib for some compilers. */ + #ifdef _COMPILING_NEWLIB +-int _EXFUN(_fstat,( int __fd, struct stat *__sbuf )); ++int _EXFUN(_fstat,( int __fd, struct stat *__sbuf )) ++#ifdef __MINIOS__ ++ asm("fstat64") ++#endif ++ ; + int _EXFUN(_stat,( const char *__path, struct stat *__sbuf )); + #ifdef __LARGE64_FILES + struct stat64; +--- ./newlib/libc/include/_syslist.h.orig 2008-08-07 16:24:19.122605000 +0100 ++++ ./newlib/libc/include/_syslist.h 2008-08-07 16:24:21.548628000 +0100 +@@ -14,6 +14,7 @@ + #define _kill kill + #define _link link + #define _lseek lseek ++#define _lseek64 lseek64 + #define _open open + #define _read read + #define _sbrk sbrk +--- newlib/libc/include/reent.h.orig 2008-08-07 16:28:49.846502000 +0100 ++++ newlib/libc/include/reent.h 2008-08-07 16:29:02.096586000 +0100 +@@ -87,6 +87,9 @@ + #if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB) + #define stat64 __stat64 + #endif ++#if defined(__MINIOS__) ++#define stat64 stat ++#endif + + struct stat64; +
Re: [PATCH] caml-stubdom: turn off_t 64bit on x86 [Was: Problems building caml-stubdom]
Quoted 3 lines · Geoffrey Lefebvre, le Thu 07 Aug 2008 16:42:40 -0700, a écrit :
To answer your question on your previous email, I am running a 32 bit xen. Thanks for the patch. I can now build the caml stubdom on 32 bit debian 4.0 and run the mini-os caml domain.
Cool, good to know!
Samuel