Skip to content

SerJaimeLannister/Cosmocc-nim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

this is a project to compile nim code to Actually Portable Executable with the help of cosmocc & cosmopolitan

the intention of creating this project is that the cosmonim repository https://github.com/rfesi/cosmonim uses cosmopolitan-amalgamation which in the newer versions of cosmopolitan don't exist Instead this uses cosmocc.

I really suck at writing so this time I have forced myself to write as clearly as possible without much edgecases

steps to use this

  1. Install Latest Version of Cosmocc
  • you could do this by installing it from your package manager (for example , archlinux supports it , but then you would need to look where its located which is not recommended)
  • (preferred) by going to https://cosmo.zip/pub/cosmocc/ and then downloading the latest version
  1. Extract the zip file

  2. Go to the folder where you extracted and get its path (by doing pwd for example)

  3. Run this command and change /path/to/cosmo-folder to actual folder where its located (paste the path from step 3)

On Linux / Mac OS / BSD

export CC=/path/to/cosmo-folder/bin/cosmocc #change the path to actual folder

On Windows (I don't use windows but I searched on stackoverflow and it seems that this command should work though I am not sure)

[Environment]::SetEnvironmentVariable("CC", "C:\path\to\folder", "User")

  1. Then create a nim file and nim.cfg (install nim if you haven't)

  2. Update: though this works , After some help by Jart , It seems that if you really want threads then you can do the following (This github issue helped me fixing it nim-lang/Nim#22392)

then copy one of these into your nim.cfg also change the operating system tag in the config to the one you are using I suppose

If you want threads then paste the following (Threads solution)

--os:linux
--gc:orc # Not required, but ARC/ORC would obviously work much better for a target like Cosmopolitan
--threads:on # Nim 2 enables threads by default, disable them since I don't think they're needed?
--cc:env
-d:useMalloc

Non threads solution

--os:linux
--gc:orc # Not required, but ARC/ORC would obviously work much better for a target like Cosmopolitan
--threads:off # Nim 2 enables threads by default, disable them since I don't think they're needed?
--cc:env
  1. run nim c file_name.nim which should create a binary in the ape format.

this was created with the help of https://github.com/jart/ & https://github.com/ahgamut/

this couldn't have been made without their help

please go sponsor them if possible

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages