mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 11:27:29 +00:00
Remove Nim support from toolchain
Nim components are best build externally using the Nimble tools and a Genode SDK. See https://github.com/ehmry/nim-genode Fix #2949
This commit is contained in:
parent
aeb7ab4774
commit
8cb8082206
@ -102,48 +102,6 @@ CUSTOM_ADA_INCLUDE ?= -I- $(INCLUDES)
|
||||
$(MSG_CONVERT)$@
|
||||
$(VERBOSE)ar p $< $*.0.o > $@
|
||||
|
||||
#
|
||||
# Compiling Nim source code
|
||||
#
|
||||
ifneq ($(SRC_NIM),)
|
||||
|
||||
ifeq ($(NIM_CPU),)
|
||||
$(warning NIM_CPU not defined for any of the following SPECS: $(SPECS))
|
||||
else
|
||||
|
||||
ifeq ($(wildcard $(NIM)),)
|
||||
$(error Nim compiler not found at $(NIM), see the 'tool/tool_chain_nim' script)
|
||||
endif
|
||||
|
||||
NIM_MAKEFILES := $(foreach X,$(SRC_NIM),$(X).mk)
|
||||
|
||||
NIM_ARGS = --compileOnly --os:genode --cpu:$(NIM_CPU)
|
||||
NIM_ARGS += --verbosity:0 --hint[Processing]:off --nimcache:.
|
||||
NIM_ARGS += --noCppExceptions
|
||||
NIM_ARGS += $(foreach DIR,$(foreach REP,$(REPOSITORIES),$(wildcard $(REP)/include/nim)), --path:$(DIR))
|
||||
NIM_ARGS += $(NIM_OPT)
|
||||
|
||||
# Generate the C++ sources and compilation info
|
||||
#
|
||||
# Unfortunately the existing sources must be purged
|
||||
# because of comma problems in the JSON recipe
|
||||
%.nim.mk: %.nim
|
||||
$(MSG_BUILD)$(basename $@).cpp
|
||||
$(VERBOSE) rm -f stdlib_*.cpp
|
||||
$(VERBOSE)$(NIM) compileToCpp $(NIM_ARGS) $<
|
||||
$(VERBOSE)$(JQ) --raw-output '"SRC_O_NIM +=" + (.link | join(" ")) +"\n" + (.compile | map((.[0] | sub("cpp$$";"o: ") | sub("c$$";"o: ")) + .[0] + "\n\t"+(.[1] | sub("^g\\++";"$$(MSG_COMP)$$@\n\t$$(VERBOSE)$$(NIM_CC)"))) | join("\n"))' < $(basename $(basename $@)).json > $@
|
||||
|
||||
NIM_CC := $(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -D__GENODE__
|
||||
|
||||
# Parse the generated makefiles
|
||||
-include $(NIM_MAKEFILES)
|
||||
|
||||
# Append the new objects
|
||||
SRC_O += $(sort $(SRC_O_NIM))
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Assembler files that must be preprocessed are fed to the C compiler.
|
||||
#
|
||||
|
@ -54,16 +54,6 @@ GNATMAKE = $(CUSTOM_GNATMAKE)
|
||||
HOST_CC = $(CUSTOM_HOST_CC)
|
||||
ADA_CC = $(CUSTOM_ADA_CC)
|
||||
|
||||
#
|
||||
# Nim toolchain
|
||||
#
|
||||
NIM ?= /usr/local/genode-nim/bin/nim
|
||||
|
||||
#
|
||||
# JSON parsing utility
|
||||
#
|
||||
JQ ?= jq
|
||||
|
||||
#
|
||||
# Compiler and Linker options
|
||||
#
|
||||
|
@ -5,8 +5,6 @@ REP_INC_DIR += include/spec/arm
|
||||
|
||||
SPECS += 32bit
|
||||
|
||||
NIM_CPU ?= arm
|
||||
|
||||
#
|
||||
# Prevent compiler message
|
||||
# "note: the mangling of 'va_list' has changed in GCC 4.4"
|
||||
|
@ -1,2 +1 @@
|
||||
CC_OPT += -DGENODE_RELEASE
|
||||
NIM_OPT += -d:release
|
||||
|
@ -16,7 +16,5 @@ CC_MARCH ?= -march=i686 -m32
|
||||
LD_MARCH ?= -melf_i386
|
||||
AS_MARCH ?= -march=i686 --32
|
||||
|
||||
NIM_CPU ?= i386
|
||||
|
||||
include $(BASE_DIR)/mk/spec/32bit.mk
|
||||
include $(BASE_DIR)/mk/spec/x86.mk
|
||||
|
@ -20,7 +20,5 @@ CC_MARCH ?= -m64 -mcmodel=large
|
||||
#
|
||||
LD_MARCH ?= -melf_x86_64
|
||||
|
||||
NIM_CPU ?= amd64
|
||||
|
||||
include $(BASE_DIR)/mk/spec/64bit.mk
|
||||
include $(BASE_DIR)/mk/spec/x86.mk
|
||||
|
@ -53,8 +53,3 @@ CC_OPT += -D__ISO_C_VISIBLE=1999
|
||||
# or 'sincosf', which is a GNU extension, not provided by our libc.
|
||||
#
|
||||
CC_OPT += -fno-builtin-sin -fno-builtin-cos -fno-builtin-sinf -fno-builtin-cosf
|
||||
|
||||
#
|
||||
# Enable Nim POSIX support when linking with this library
|
||||
#
|
||||
NIM_OPT += -d:posix
|
||||
|
@ -1 +0,0 @@
|
||||
NIM_OPT += --threads:on --tlsEmulation:on
|
@ -1,110 +0,0 @@
|
||||
import unittest
|
||||
const
|
||||
Text = "Hello world!"
|
||||
|
||||
suite "echo":
|
||||
echo Text
|
||||
|
||||
suite "system":
|
||||
echo "compile date: ", CompileDate, " - ", CompileTime
|
||||
echo("endianness: ",
|
||||
case cpuEndian:
|
||||
of littleEndian:
|
||||
"littleEndian"
|
||||
of bigEndian:
|
||||
"bigEndian"
|
||||
)
|
||||
echo "hostCPU: ", hostCPU
|
||||
echo "NimVersion: ", NimVersion
|
||||
echo "nativeStackTraceSupported: ", $nativeStackTraceSupported
|
||||
echo "getStackTrace:\n", getStackTrace()
|
||||
echo "getFreeMem: ", getFreeMem()
|
||||
echo "getTotalMem: ", getTotalMem()
|
||||
echo "getOccupiedMem: ", getOccupiedMem()
|
||||
|
||||
test "isMainModule":
|
||||
assert isMainModule == true
|
||||
test "hostOS == genode":
|
||||
assert hostOS == "genode"
|
||||
|
||||
test "alloc/dealloc":
|
||||
let p = alloc 768
|
||||
assert(not p.isNil)
|
||||
dealloc p
|
||||
|
||||
test "exception handling":
|
||||
type NovelError = object of SystemError
|
||||
try: raise newException(NovelError, "test exception")
|
||||
except NovelError:
|
||||
discard
|
||||
|
||||
import locks, threadpool
|
||||
suite "threadpool":
|
||||
|
||||
test "spawn":
|
||||
var L: Lock
|
||||
|
||||
proc threadProc(interval: tuple[a,b: int]) =
|
||||
for i in interval.a..interval.b:
|
||||
acquire L
|
||||
echo i
|
||||
release L
|
||||
|
||||
initLock L
|
||||
for i in 0..3:
|
||||
spawn threadProc((i*10, i*10+4))
|
||||
sync()
|
||||
deinitLock L
|
||||
|
||||
test "threadvar":
|
||||
var
|
||||
L: Lock
|
||||
x {.threadvar.}: int
|
||||
y: int
|
||||
|
||||
proc printVal(id: string) =
|
||||
acquire L
|
||||
echo(
|
||||
id,
|
||||
" x: ", repr(addr(x)),
|
||||
" y: ", repr(addr(y))
|
||||
)
|
||||
inc x
|
||||
inc y
|
||||
release L
|
||||
|
||||
initLock L
|
||||
release L
|
||||
printVal("main thread")
|
||||
for i in 1..4:
|
||||
spawn printVal("spawn "& $i)
|
||||
sync()
|
||||
deinitLock L
|
||||
|
||||
suite "I/O":
|
||||
const
|
||||
TestFile = "/testfile"
|
||||
Text = NimVersion & " - " & CompileDate & " - " & CompileTime
|
||||
test "writeFile":
|
||||
writeFile(TestFile, Text)
|
||||
test "readFile":
|
||||
assert readFile(TestFile) == Text
|
||||
|
||||
suite "staticExec":
|
||||
const rev = staticExec("git describe")
|
||||
echo "compile time 'git describe': ", rev
|
||||
|
||||
import times
|
||||
suite "time":
|
||||
|
||||
echo "epochTime() float value: ", epochTime()
|
||||
echo "getTime() float value: ", toSeconds(getTime())
|
||||
echo "cpuTime() float value: ", cpuTime()
|
||||
echo "An hour from now : ", getLocalTime(getTime()) + 1.hours
|
||||
echo "An hour from (UTC) now: ", getGmTime(getTime()) + initInterval(0,0,0,1)
|
||||
|
||||
suite "garbage collector":
|
||||
echo GC_getStatistics()
|
||||
|
||||
echo "done"
|
||||
quit 0
|
@ -1,8 +0,0 @@
|
||||
TARGET = test-nim
|
||||
LIBS = nim-threads libc
|
||||
SRC_NIM = main.nim
|
||||
|
||||
# Enable extra system assertions
|
||||
NIM_OPT += -d:useSysAssert
|
||||
|
||||
CC_CXX_WARN_STRICT =
|
@ -1,27 +0,0 @@
|
||||
import asyncnet, asyncdispatch
|
||||
|
||||
const
|
||||
CRLF* = "\c\L"
|
||||
|
||||
proc processClient(address: string, client: AsyncSocket) {.async.} =
|
||||
echo "accepted connection from ", address
|
||||
while not client.isClosed():
|
||||
let line = await client.recvLine()
|
||||
if line == "":
|
||||
break
|
||||
await client.send(line & CRLF)
|
||||
echo address, " closed connection"
|
||||
|
||||
proc serve() {.async.} =
|
||||
let server = newAsyncSocket()
|
||||
server.bindAddr(7.Port)
|
||||
server.listen()
|
||||
|
||||
echo "echo service listening on port 7"
|
||||
|
||||
while true:
|
||||
let res = await server.acceptAddr()
|
||||
asyncCheck processClient(res[0], res[1])
|
||||
|
||||
asyncCheck serve()
|
||||
runForever()
|
@ -1,8 +0,0 @@
|
||||
TARGET = test-nim_echo_server
|
||||
LIBS = libc
|
||||
SRC_NIM = main.nim
|
||||
|
||||
# Enable extra system assertions
|
||||
NIM_OPT += -d:useSysAssert
|
||||
|
||||
CC_CXX_WARN_STRICT =
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/make -f
|
||||
#
|
||||
# \brief Tool for preparing the Nim tool-chain for the Genode OS Framework
|
||||
# \author Emery Hemingway
|
||||
# \date 2017-07-04
|
||||
#
|
||||
|
||||
help:
|
||||
@$(ECHO)
|
||||
@$(ECHO) "Build Nim compiler for the Genode OS Framework tool chain"
|
||||
@$(ECHO)
|
||||
@$(ECHO) "--- available commands ---"
|
||||
@$(ECHO) "build - build Nim compiler"
|
||||
@$(ECHO) "clean - clean everything except contrib sources"
|
||||
@$(ECHO) "install - copy Nim compiler and standard library to '$(INSTALL_LOCATION)'"
|
||||
@$(ECHO)
|
||||
|
||||
.PHONY: help install
|
||||
|
||||
GENODE_DIR ?= $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/..)
|
||||
include $(GENODE_DIR)/tool/ports/mk/common.inc
|
||||
|
||||
LOCAL_INSTALL_LOCATION ?= /usr/local
|
||||
INSTALL_LOCATION := $(LOCAL_INSTALL_LOCATION)/genode-nim
|
||||
|
||||
NIM_CONTRIB_DIR = $(shell $(GENODE_DIR)/tool/ports/current nim)
|
||||
|
||||
BUILD_DIR = build/nim
|
||||
|
||||
install: build
|
||||
@$(ECHO) "$(BRIGHT_COL)installing Nim to '$(INSTALL_LOCATION)'...$(DEFAULT_COL)"
|
||||
$(VERBOSE)sudo rm -rf $(INSTALL_LOCATION)
|
||||
$(VERBOSE)sudo mkdir -p $(INSTALL_LOCATION)
|
||||
$(VERBOSE)sudo cp -a $(BUILD_DIR)/* $(INSTALL_LOCATION)
|
||||
|
||||
build: $(BUILD_DIR)/bin/nim $(BUILD_DIR)/koch
|
||||
|
||||
$(BUILD_DIR)/bin/nim: $(BUILD_DIR)/koch
|
||||
@$(ECHO) "$(BRIGHT_COL)building Nim compiler...$(DEFAULT_COL)"
|
||||
$(VERBOSE)cd $(BUILD_DIR) && ./koch boot -d:release --verbosity:0 --hint[Processing]:off
|
||||
|
||||
$(BUILD_DIR)/koch: $(BUILD_DIR)/.bootstrap.tag
|
||||
@$(ECHO) "$(BRIGHT_COL)building Koch...$(DEFAULT_COL)"
|
||||
$(VERBOSE)cd $(BUILD_DIR) && ./bin/nim c koch
|
||||
|
||||
$(BUILD_DIR)/.bootstrap.tag: $(BUILD_DIR)/build.sh
|
||||
@$(ECHO) "$(BRIGHT_COL)building bootstrap compiler...$(DEFAULT_COL)"
|
||||
$(VERBOSE)cd $(BUILD_DIR) && sh build.sh
|
||||
@touch $@
|
||||
|
||||
$(BUILD_DIR)/build.sh: $(NIM_CONTRIB_DIR)
|
||||
@$(ECHO) "$(BRIGHT_COL)copying Nim sources...$(DEFAULT_COL)"
|
||||
$(VERBOSE)mkdir -p $(BUILD_DIR)
|
||||
$(VERBOSE)cp -a $</* $(BUILD_DIR)
|
||||
|
||||
$(NIM_CONTRIB_DIR):
|
||||
@$(ECHO) "$(BRIGHT_COL)preparing Nim...$(DEFAULT_COL)"
|
||||
$(VERBOSE)$(GENODE_DIR)/tool/ports/prepare_port nim
|
||||
|
||||
clean:
|
||||
$(VERBOSE)rm -rf $(BUILD_DIR)
|
Loading…
x
Reference in New Issue
Block a user