Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Apr 2014 20:22:51 GMT
From:      Matthew Pherigo <hybrid120+pr@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/188326: [patch] lang/nimrod compiler misbehaves without a procfs
Message-ID:  <201404062022.s36KMpQR080209@cgiserv.freebsd.org>
Resent-Message-ID: <201404062030.s36KU0nY021548@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         188326
>Category:       ports
>Synopsis:       [patch] lang/nimrod compiler misbehaves without a procfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 06 20:30:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Pherigo
>Release:        10-RELEASE
>Organization:
>Environment:
FreeBSD Chiyochan 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Fri Jan 17 01:46:25 UTC 2014 root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
>Description:
When attempting to compile programs with the lang/nimrod port while not having a mounted procfs at /proc, calls to the C compiler often use paths that are missing the root slash. This usually results in calls that go something like this; assuming the file we want to compile is /foo/bar/baz.nim:
matt: /foo/bar $ nimrod c -r baz.nim
(Nimrod converts the Nimrod file to C, but instead of putting it in /foo/bar/nimcache/baz.c, it puts it in foo/bar/nimcache/baz.c )
cc -o foo/bar/nimcache/baz.o foo/bar/nimcache/baz.c
At this point, of course, all of the files are located in /foo/bar/foo/bar/nimcache/. Not only does this mean junk folders accumulate everywhere, but more complex compilations that depend on external library .nim files will actually fail, due to some of the calls in this process actually having the forward slash they are supposed to have.
Here's some example output. The first one is a simple, single Nimrod file, and the second one is a more complex .nim file that depends on strutils.nim.
EXAMPLE ONE:
[matt@Chiyochan /usr/home/matt/MyProjects/Challenges-Nimrod/Mine]$ nimrod c -r hello2.nim                                                     usr/local/etc/nimrod.cfg(38, 11) Hint: added path: '/home/matt/.babel/libs/' [Path]
Hint: used config file '/etc/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hello2 [Processing]
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/hello2.o usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/hello2.c
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/system.o usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/system.c
clang   -o /usr/home/matt/MyProjects/Challenges-Nimrod/Mine/hello2  usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/system.o usr/home/matt/MyProjects/Challenges-Nimrod/Mine/nimcache/hello2.o 
Hint: operation successful (7438 lines compiled; 3.469 sec total; 7.768MB) [SuccessX]
/usr/home/matt/MyProjects/Challenges-Nimrod/Mine/hello2 
What's your name? 
Matt
Hi, Matt!
[matt@Chiyochan /usr/home/matt/MyProjects/Challenges-Nimrod/Mine]$
EXAMPLE TWO:
[matt@Chiyochan /usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc]$ nimrod c -r calc1.nim 
usr/local/etc/nimrod.cfg(38, 11) Hint: added path: '/home/matt/.babel/libs/' [Path]
Hint: used config file '/etc/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: calc1 [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/calc1.nim(3, 11) Hint: 'c' is declared but not used [XDeclaredButNotUsed]
usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/calc1.nim(3, 8) Hint: 'b' is declared but not used [XDeclaredButNotUsed]
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/calc1.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/calc1.c
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/system.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/system.c
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/strutils.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/strutils.c
clang -c -w -I/usr/local/lib/nimrod -o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/parseutils.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/parseutils.c
clang   -o /usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/calc1  usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/parseutils.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/strutils.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/system.o usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/calc1.o 
clang: error: no such file or directory: 'usr/home/matt/MyProjects/Challenges-Nimrod/Numbers/calc/nimcache/system.o'
Error: execution of an external program failed

>How-To-Repeat:
Compile a program with Nimrod without having a mounted procfs.
>Fix:
Disabling the dependence of Nimrod on procfs immediately fixes the problem. The patch attached shows which lines to remove. The patch was written by Tijl Coosemans (tijl@coosemans.org) and I take no credit for it. I'm not even sure why exactly it works, but it does.

Patch attached with submission follows:

--- lib/pure/os.nim.orig
+++ lib/pure/os.nim
@@ -1389,8 +1389,6 @@
     result = getApplAux("/proc/self/exe")
   elif defined(solaris):
     result = getApplAux("/proc/" & $getpid() & "/path/a.out")
-  elif defined(freebsd):
-    result = getApplAux("/proc/" & $getpid() & "/file")
   elif defined(macosx):
     var size: cuint32
     getExecPath1(nil, size)
@@ -1399,16 +1397,14 @@
       result = "" # error!
   else:
     # little heuristic that may work on other POSIX-like systems:
-    result = string(getEnv("_"))
-    if len(result) == 0:
-      result = string(ParamStr(0))
-      # POSIX guaranties that this contains the executable
-      # as it has been executed by the calling process
-      if len(result) > 0 and result[0] != DirSep: # not an absolute path?
-        # iterate over any path in the $PATH environment variable
-        for p in split(string(getEnv("PATH")), {PathSep}):
-          var x = joinPath(p, result)
-          if ExistsFile(x): return x
+    result = string(ParamStr(0))
+    # POSIX guaranties that this contains the executable
+    # as it has been executed by the calling process
+    if len(result) > 0 and result[0] != DirSep: # not an absolute path?
+      # iterate over any path in the $PATH environment variable
+      for p in split(string(getEnv("PATH")), {PathSep}):
+        var x = joinPath(p, result)
+        if ExistsFile(x): return x
 
 proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} =
   ## Returns the filename of the application's executable.


>Release-Note:
>Audit-Trail:
>Unformatted:



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