From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Apr 6 20:30:00 2014 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B37D9EED for ; Sun, 6 Apr 2014 20:30:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E84F91A for ; Sun, 6 Apr 2014 20:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s36KU0ig021549 for ; Sun, 6 Apr 2014 20:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s36KU0nY021548; Sun, 6 Apr 2014 20:30:00 GMT (envelope-from gnats) Resent-Date: Sun, 6 Apr 2014 20:30:00 GMT Resent-Message-Id: <201404062030.s36KU0nY021548@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Matthew Pherigo Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6FA5FD1A for ; Sun, 6 Apr 2014 20:22:52 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59EBD89C for ; Sun, 6 Apr 2014 20:22:52 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s36KMqgq080216 for ; Sun, 6 Apr 2014 20:22:52 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s36KMpQR080209; Sun, 6 Apr 2014 20:22:51 GMT (envelope-from nobody) Message-Id: <201404062022.s36KMpQR080209@cgiserv.freebsd.org> Date: Sun, 6 Apr 2014 20:22:51 GMT From: Matthew Pherigo To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/188326: [patch] lang/nimrod compiler misbehaves without a procfs X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Apr 2014 20:30:00 -0000 >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: