Porting Racket

Unxmaal

Administrator
Feb 8, 2019
69
29
18
For $reasons, I decided to try to port Racket.

It went ok.

Then a long time later, it failed at this point:
Code:
racket/racketcgc -X "/usr/people/edodd/buildcrap/racket-7.5/racket/collects" -G "/usr/people/edodd/buildcrap/racket-7.5/racket/etc"  -G /usr/peo
ple/edodd/buildcrap/racket-7.5/build/config  --no-user-path -N "raco" -l- setup --no-user
raco setup: bootstrapping from source...
 triggered by use of non-".zo" file
  path: /usr/people/edodd/buildcrap/racket-7.5/racket/collects/compiler/private/cm-minimal.rkt
getenv: contract violation
  expected: string-environment-variable-name?
  given: #f
  context...:
   /usr/people/edodd/buildcrap/racket-7.5/racket/collects/racket/private/misc.rkt:202:2: getenv
   /usr/people/edodd/buildcrap/racket-7.5/racket/collects/openssl/mzssl.rkt:374:0: x509-root-sources
make[6]: *** [Makefile:221: install-cgc] Error 1
Here's the patch so far:

C:
--- racket-7.5.orig/racket/src/rktio/rktio_envvars.c    2019-11-18 10:44:10.000000000 +0000
+++ racket-7.5/racket/src/rktio/rktio_envvars.c 2020-01-24 16:38:57.444023520 +0000
@@ -9,6 +9,21 @@
   char **vals;
 };

+
+setenv(const char *name, const char *value, int o)
+{
+    size_t len = strlen(name) + strlen(value) + 1;
+    char *s = malloc(len+1);
+    int ret;
+
+    snprintf(s, len, "%s=%s", name, value);
+    ret = putenv(s);
+    free(s);
+    return ret;
+}
+
+#define unsetenv(x) setenv(x, "", 1)
+
 #ifdef OS_X
 # define SETENV_DROPS_LEADING_EQUAL_SIGN
 #endif
diff -ru racket-7.5.orig/racket/src/rktio/rktio_ltps.c racket-7.5/racket/src/rktio/rktio_ltps.c
--- racket-7.5.orig/racket/src/rktio/rktio_ltps.c       2019-11-18 10:44:10.000000000 +0000
+++ racket-7.5/racket/src/rktio/rktio_ltps.c    2020-01-24 16:39:14.953661680 +0000
@@ -23,6 +23,7 @@
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <sys/resource.h>

 #ifdef RKTIO_SYSTEM_UNIX
 # define LTPS_USE_HASH_TABLE
diff -ru racket-7.5.orig/racket/src/rktio/rktio_poll_set.c racket-7.5/racket/src/rktio/rktio_poll_set.c
--- racket-7.5.orig/racket/src/rktio/rktio_poll_set.c   2019-11-18 10:44:10.000000000 +0000
+++ racket-7.5/racket/src/rktio/rktio_poll_set.c        2020-01-24 16:39:30.776566160 +0000
@@ -15,6 +15,7 @@
 #endif
 #include <string.h>
 #include <stdlib.h>
+#include <sys/resource.h>

 /*========================================================================*/
 /* Poll variant                                                           */
 
  • Like
Reactions: Elf

Unxmaal

Administrator
Feb 8, 2019
69
29
18
The section of the code in question:

Code:
  ;; -------------------------------------------------------------------------

  (define (string-no-nuls? s)
    (and (string? s)
         (not (regexp-match? #rx"\0" s))))

  (define (bytes-environment-variable-name? s)
    (and (bytes? s)
         (if (eq? 'windows (system-type))
             (regexp-match? #rx#"^[^\0=]+$" s)
             (regexp-match? #rx#"^[^\0=]*$" s))))

  (define (string-environment-variable-name? s)
    (and (string? s)
         (bytes-environment-variable-name?
          (string->bytes/locale s (char->integer #\?)))))

  (define (getenv s)
    (unless (string-environment-variable-name? s)
      (raise-argument-error 'getenv "string-environment-variable-name?" s))
    (let ([v (environment-variables-ref (current-environment-variables)
                                        (string->bytes/locale s (char->integer #\?)))])
      (and v
           (bytes->string/locale v #\?))))

  (define (putenv s t)
    (unless (string-no-nuls? s)
      (raise-argument-error 'putenv "string-environment-variable-name?" 0 s t))
    (unless (string-no-nuls? t)
      (raise-argument-error 'putenv "string-no-nuls?" 1 s t))
    (and
     (environment-variables-set! (current-environment-variables)
                                 (string->bytes/locale s (char->integer #\?))
                                 (string->bytes/locale t (char->integer #\?))
                                 (lambda () #f))
     #t))
 

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu