Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for compilation in QNX #8141

Closed
vicuna opened this issue May 7, 2003 · 3 comments
Closed

Patch for compilation in QNX #8141

vicuna opened this issue May 7, 2003 · 3 comments

Comments

@vicuna
Copy link

vicuna commented May 7, 2003

Original bug ID: 1680
Reporter: administrator
Status: resolved (set by @damiendoligez on 2017-03-03T16:41:26Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: platform support (windows, cross-compilation, etc)
Tags: patch

Bug description

Hi,

This diff against the current CVS version will let ocaml compile nicely
in QNX, specifically QNX 6.2.1 on an x86 machine. I don't have access
to any other architectures so I haven't bothered trying to support them.

There are basically just some configure and i386 code generator changes
to recognise QNX, the socket functions are in libsocket but there is no
libnsl, and mmap'ed memory access isn't synced to the file. The
MAP_NOSYNCFILE just says that I don't care about that, so read only
access will work, read/write will fail since the flag isn't used (an
explicit msync call would be needed to sync any changes.)

Julian Kinraid

Index: configure

RCS file: /caml/ocaml/configure,v
retrieving revision 1.186
diff -u -r1.186 configure
--- configure 2003/05/02 12:48:55 1.186
+++ configure 2003/05/07 11:10:34
@@ -452,7 +452,7 @@

if test $withsharedlibs = "yes"; then
case "$host" in

  • --linux-gnu|--linux|--freebsd[3-9]*)
  • --linux-gnu|--linux|--freebsd[3-9]|--nto)
    sharedcccompopts="-fPIC"
    mksharedlib="$bytecc -shared -o"
    bytecclinkopts="$bytecclinkopts -Wl,-E"
    @@ -538,6 +538,7 @@
    i[3456]86--solaris) arch=i386; system=solaris;;
    i[3456]86--beos) arch=i386; system=beos;;
    i[3456]86--cygwin) arch=i386; system=cygwin;;
  • x86--nto) arch=i386; system=qnxnto;;
    mips--irix6) arch=mips; system=irix;;
    hppa1.1--hpux) arch=hppa; system=hpux;;
    hppa1.1--nextstep) arch=hppa; system=nextstep;;
    @@ -617,6 +618,7 @@
    alpha,,digital) profiling='prof';;
    i386,
    ,linux_elf) profiling='prof';;
    i386,*,bsd_elf) profiling='prof';;
  • i386,,qnxnto) profiling='prof';;
    sparc,
    ,solaris)
    profiling='prof'
    case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
    @@ -754,6 +756,11 @@
    cclibs="$cclibs -lnsl -lsocket"
    echo "#define HAS_SOCKETS" >> s.h
    has_sockets=yes
    +elif sh ./hasgot -lsocket socket socketpair bind listen accept connect; then
  • echo "You have BSD sockets (with library '-lsocket')"
  • cclibs="$cclibs -lsocket"
  • echo "#define HAS_SOCKETS" >> s.h
  • has_sockets=yes
    fi

if sh ./hasgot -i sys/socket.h -t socklen_t; then
@@ -1024,6 +1031,7 @@
) bignum_arch=C;;
esac;;
i[3456]86-
-beos) bignum_arch=x86;;

  • x86--nto) bignum_arch=x86;;
    i[3456]86-*-bsd)
    case sh ./runtest elf.c in
    elf) bignum_arch=x86;;
    @@ -1060,6 +1068,8 @@
    bytecccompopts="$bytecccompopts -pthread"
    asppflags="$asppflags -pthread"
    nativecccompopts="$nativecccompopts -pthread";;
  • --nto*)
  •    pthread_link="";;
    
    *)
    pthread_link="-lpthread";;
    esac
    Index: asmcomp/i386/emit.mlp
    ===================================================================
    RCS file: /caml/ocaml/asmcomp/i386/emit.mlp,v
    retrieving revision 1.26
    diff -u -r1.26 emit.mlp
    --- asmcomp/i386/emit.mlp 2003/04/25 12:26:59 1.26
    +++ asmcomp/i386/emit.mlp 2003/05/07 11:10:37
    @@ -52,6 +52,7 @@
    | "bsd_elf" -> ""
    | "solaris" -> ""
    | "beos" -> ""
  • | "qnxnto" -> ""
    | _ -> "_"

let emit_symbol s =
@@ -65,6 +66,7 @@
| "bsd_elf" -> ".L"
| "solaris" -> ".L"
| "beos" -> ".L"

  • | "qnxnto" -> ".L"
    | _ -> "L"

let emit_label lbl =
@@ -92,7 +94,7 @@

let emit_align =
match Config.system with

  • "linux_elf" | "bsd_elf" | "solaris" | "beos" | "cygwin" | "mingw" ->
  • "linux_elf" | "bsd_elf" | "solaris" | "beos" | "cygwin" | "mingw" | "qnxnto" ->
    (fun n -> .align {emit_int n}\n)
    | _ ->
    (fun n -> .align {emit_int(Misc.log2 n)}\n)
    Index: asmrun/i386.S
    ===================================================================
    RCS file: /caml/ocaml/asmrun/i386.S,v
    retrieving revision 1.38
    diff -u -r1.38 i386.S
    --- asmrun/i386.S 2002/06/07 09:49:36 1.38
    +++ asmrun/i386.S 2003/05/07 11:10:38
    @@ -26,7 +26,7 @@
    #endif

#if defined(SYS_linux_elf) || defined(SYS_bsd_elf) \

  • || defined(SYS_solaris) || defined(SYS_beos)
  • || defined(SYS_solaris) || defined(SYS_beos) || defined(SYS_qnxnto)
    #define G(x) x
    #define LBL(x) CONCAT(.L,x)
    #else
    @@ -36,7 +36,7 @@

#if defined(SYS_linux_elf) || defined(SYS_bsd_elf)
|| defined(SYS_solaris) || defined(SYS_beos) || defined(SYS_cygwin) \

  • || defined(SYS_mingw)
  • || defined(SYS_mingw) || defined(SYS_qnxnto)
    #define FUNCTION_ALIGN 4
    #else
    #define FUNCTION_ALIGN 2
    @@ -57,6 +57,13 @@
    popl %edx; popl %ecx; popl %eax; popl %ebp
    #define PROFILE_C
    pushl %ebp; movl %esp, %ebp; call .mcount; popl %ebp
    +#elif defined(SYS_qnxnto)
    +#define PROFILE_CAML \
  •    pushl %ebp; movl %esp, %ebp; pushl %eax; pushl %ecx; pushl %edx; \
    
  •    call _mcount; \
    
  •    popl %edx; popl %ecx; popl %eax; popl %ebp
    

+#define PROFILE_C \

  •    pushl %ebp; movl %esp, %ebp; call _mcount; popl %ebp
    

#endif
#else
#define PROFILE_CAML
Index: boot/ocamlc

RCS file: /caml/ocaml/boot/ocamlc,v
retrieving revision 1.286
diff -u -r1.286 ocamlc
Binary files /tmp/cvsyoeLp65423 and ocamlc differ
Index: otherlibs/bigarray/mmap_unix.c

RCS file: /caml/ocaml/otherlibs/bigarray/mmap_unix.c,v
retrieving revision 1.7
diff -u -r1.7 mmap_unix.c
--- otherlibs/bigarray/mmap_unix.c 2001/12/07 13:39:50 1.7
+++ otherlibs/bigarray/mmap_unix.c 2003/05/07 11:12:43
@@ -90,7 +90,11 @@
/* Restore original file position /
lseek(fd, currpos, SEEK_SET);
/
Do the mmap */
+#ifdef QNXNTO

  • shared = Bool_val(vshared) ? MAP_SHARED : MAP_PRIVATE | MAP_NOSYNCFILE;
    +#else
    shared = Bool_val(vshared) ? MAP_SHARED : MAP_PRIVATE;
    +#endif
    addr = mmap(NULL, array_size, PROT_READ | PROT_WRITE, shared, fd, 0);
    if (addr == (void ) MAP_FAILED) sys_error(NO_ARG);
    /
    Build and return the Caml bigarray */
@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

This patch was submitted 13 years ago and to my knowledge there are not users clamouring to run OCaml on QNX. Is this something we wish to support?

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

(My gut feeling is no.)

@vicuna
Copy link
Author

vicuna commented Mar 3, 2017

Comment author: @damiendoligez

If anyone wants to run OCaml on QNX, feel free to reopen this or (even better) open a PR on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant