Hello,
I need to modify the following code so that Nim can works on old linux (centos 5 )
I am not sure if this is okay.
And, Is it is possible that nim support older linux by some compiler flag ?
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 8560c3e..2825066 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -886,8 +886,7 @@ elif not defined(useNimRtl):
discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
exitnow(1)
- when defined(macosx) or defined(freebsd) or defined(netbsd) or defined(android):
- var environ {.importc.}: cstringArray
+ var environ {.importc.}: cstringArray
proc startProcessAfterFork(data: ptr StartProcessData) =
# Warning: no GC here!
@@ -916,17 +915,8 @@ elif not defined(useNimRtl):
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
if data.optionPoUsePath:
- when defined(macosx) or defined(freebsd) or defined(netbsd) or defined(android):
- # MacOSX doesn't have execvpe, so we need workaround.
- # On MacOSX we can arrive here only from fork, so this is safe:
- environ = data.sysEnv
- discard execvp(data.sysCommand, data.sysArgs)
- else:
- when defined(uClibc):
- # uClibc environment (OpenWrt included) doesn't have the full execvpe
- discard execve(data.sysCommand, data.sysArgs, data.sysEnv)
- else:
- discard execvpe(data.sysCommand, data.sysArgs, data.sysEnv)
+ environ = data.sysEnv
+ discard execvp(data.sysCommand, data.sysArgs)
else:
discard execve(data.sysCommand, data.sysArgs, data.sysEnv)
https://github.com/nim-lang/Nim/pull/6299
I tried hard to get my company to upgrade the GLIBC that we use when we build for customers, but they want to wait a few months. So we really need this change, or some alternative.
I see. I had done a test which mislead me. Yes, as far as I can tell, everything works now. Thanks.
... Ugh. I just pulled Nim@devel (a43eae8e6c77149be77082388bb0fa546b9c97a7) and rebuilt according to readme.md:
c_code/2_2/stdlib_osproc.o: In function `startProcessAfterFork_kP8IoxkYQ0xKBWMKeIF3Cw':
stdlib_osproc.c:(.text+0x5ec): undefined reference to `execvpe'
Yes, csources needs to be updated.