yardanico / cosmonim Goto Github PK
View Code? Open in Web Editor NEWA Nim template to compile your code with the Cosmopolitan libc
License: MIT License
A Nim template to compile your code with the Cosmopolitan libc
License: MIT License
Hi,
Any reason to not merge asynchttpserver diff into Nim stdlib, and have cosmopolitan support from compiler, like have for musl?
Here's the error that I'm getting:
/usr/bin/ld.bfd: errno: TLS reference in /usr/lib64/libm-2.34.a(w_pow.o) mismatches non-TLS reference in /home/ajusa/.cache/nim/main_d/stdlib_io.nim.c.o
/usr/bin/ld.bfd: /usr/lib64/libm-2.34.a: error adding symbols: bad value
collect2: error: ld returned 1 exit status
Looks like something to do with libm. Is it trying to link against my libm rather than the cosmopolitan version maybe?
Hello, I wrote a little code to hexdump files in colors, but the produced executable seems not to be valid:
OSError: [Errno 8] Exec format error: './chex.com'
import terminal
import os
import strutils
proc reset() {.noconv.} =
stdout.write("\u001b[0m\n")
quit()
setControlCHook(reset)
let cols = terminalWidth()
var
f: File
i:int = 0
l: array[1024, uint8]
mono = false
r: int
if isatty(stdin):
case paramCount():
of 0:
echo "filename expected"
quit()
of 1:
f = open(paramStr(1), fmRead)
else:
mono = true
f = open(paramStr(2), fmRead)
else:
f = stdin
r = f.readBytes(l,0,cols*2)
while r>0:
if mono:
for j in 0..cols*2-1:
if j >= r: break
stdout.write("\u001b[38;5;" & $l[j] & "m█")
i += 1
if (i mod cols) == 0:
stdout.write("\n")
else:
for j in 0..cols-1:
if j >= r:
stdout.write("\u001b[0m" & " ".repeat(cols-j)) # for urxvt bug
break
var bg = "\u001b[48;5;" & $l[cols+j] & "m"
if r <= cols:
bg = "\u001b[49m"
stdout.write( bg & "\u001b[38;5;" & $l[j] & "m▀")
i += 1
if (i mod cols) == 0:
stdout.write("\n")
r = f.readBytes(l,0,cols*2)
reset()
Hello,
I tried using cosmonim to compile a command line project, but I got this error:
/home/ajusa/.cache/nim/main_r/stdlib_terminal.nim.c: In function ‘terminalWidth__s9bdJLFVciGfQ0i2sQaMF1g’:
/home/ajusa/.cache/nim/main_r/stdlib_terminal.nim.c:204:28: error: ‘L_ctermid’ undeclared (first use in this function)
204 | cterm = mnewString(((NI) (L_ctermid)));
My guess this is related to an OS level binding for which terminal this code is being compiled for.
https://github.com/nim-lang/Nim/blob/9819fb21d8db818c0b3027d4e6ba58dc550b77c0/lib/pure/terminal.nim#L241 appears to be the terminal code.
My nim version is
Nim Compiler Version 1.4.4 [Linux: amd64]
Compiled at 2021-02-23
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 2ff517462bf8609b30e6134c96658aa7912b628a
active boot switches: -d:release
Let me know if you need any more information!
Looks like as of Cosmopolitan 3.1 (and maybe 3?) https://github.com/jart/cosmopolitan/releases/tag/3.1 cosmocc
is included as a C compiler that uses Cosmopolitan for building binaries.
That might be an easier way to build cross platform Nim binaries, similar to the way folks have been using zig cc
and tcc
- it is easier to swap out the C compiler in Nim.
I think it is as simple as adding the following to a config.nims, but I haven't tried:
switch("cc", "cosmocc")
switch("clang.exe", "cosmocc")
switch("clang.linkerexe", "cosmocc")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.