clj-on-windows

For those interested in making clj on Windows https://dev.clojure.org/jira/browse/TDEPS-67. Also see https://github.com/littleli/scoop-clojure.
carkh 2019-07-31T06:52:30.262100Z

Now with cross compilation of the windows installer : https://github.com/cark/clojure-cli-portable

carkh 2019-07-31T06:53:02.262900Z

@sogaiu i took your input and used NSIS for this one, so you can see the files being copied !

carkh 2019-07-31T06:54:55.264500Z

Now to put the whole thing in docker so the preparation steps to make these compilations is automated

2019-07-31T06:57:01.265900Z

@carkh so it looks like the scripts need to be run from the project root -- cd to script first is a no-no, i guess 🙂 i tried script/build_all, but at the mingw32 stuff, i see:

/usr/lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld: unrecognized option '-z'
/usr/lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
Error: execution of an external program failed: '/usr/bin/x86_64-w64-mingw32-gcc   -o /home/user/Desktop/src/clojure-cli-portable/clojure.exe  /home/user/.cache/nim/clojure_r/stdlib_assertions.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_dollars.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_widestrs.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_io.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_system.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_parseutils.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_math.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_unicode.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_strutils.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_dynlib.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_winlean.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_pathnorm.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_times.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_os.nim.c.o /home/user/.cache/nim/clojure_r/parseArgs.nim.c.o /home/user/.cache/nim/clojure_r/compat_windows.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_streams.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_osproc.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_strformat.nim.c.o /home/user/.cache/nim/clojure_r/stdlib_md5.nim.c.o /home/user/.cache/nim/clojure_r/clojure.nim.c.o   -s   -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
!!!!!!!!!!!!! ERROR : COMPILE ERROR !!!!!!!!!!!!!
!!!!!!!!!!!!! ERROR : WINDOWS BUILD !!!!!!!!!!!!!

carkh 2019-07-31T06:57:58.266400Z

you need to install mingw i think

2019-07-31T06:58:04.266800Z

i have it

carkh 2019-07-31T06:58:12.267Z

let me try from trhe script directory

carkh 2019-07-31T06:59:02.267400Z

ah indeed

2019-07-31T06:59:11.267600Z

i did cd back to the project directory before running the command, fwiw

2019-07-31T06:59:41.267900Z

may be my mingw32 installation is not quite correct

carkh 2019-07-31T07:00:49.268300Z

probably, i just installed as is and it worked for me

carkh 2019-07-31T07:00:58.268500Z

you're on ubuntu ?

2019-07-31T07:01:12.268800Z

no, i'm on an arch derivative called manjaro

carkh 2019-07-31T07:02:58.269900Z

linux is not my thing, i somehow managed to do this, but that's the extent of my knowledge there

2019-07-31T07:04:13.270300Z

np

carkh 2019-07-31T07:04:15.270400Z

check https://nim-lang.org/docs/nimc.html#cross-compilation the for windows part

carkh 2019-07-31T07:05:10.271100Z

anyways that's immaterial, i'll make a docker file and that at least should work everywhere

carkh 2019-07-31T07:05:36.271500Z

the goal is to make as easy as possible

2019-07-31T07:06:54.271800Z

thanks for the hints -- i'll investigate

carkh 2019-07-31T07:14:54.272400Z

(fixed the execution of scripts from script directory)

2019-07-31T08:06:33.273200Z

thanks -- did a windows compile on windows, have transferred the output to a linux environment and am about to try the nsis script

2019-07-31T08:12:52.274400Z

the installer .exe was built successfully -- transferred it to a windows 10 pro machine and ran it. saw the license agreement, tested the details button to see the performed steps. tested clojure.exe -r on a couple of projects successfully. uninstalling worked too via the uninstallation exe. looks pretty good 🙂

2019-07-31T08:14:30.276400Z

a few things i noticed: 1) the details in the install / uninstall dialog do not appear to be selectable all-at-once -- that is, i only seem to be able to select one line at a time. i guess that's not a big deal unless you want to copy some / all of the output. 2) i tried running an alias w/ clj and i think i'm hitting a problem with an overly long command line -- do you know how one works around this sort of thing?

carkh 2019-07-31T08:20:41.277Z

oh, i think they advise to move your local maven repository

carkh 2019-07-31T08:20:47.277200Z

to a shorter path

carkh 2019-07-31T08:20:58.277500Z

but that's a shaky workaround

carkh 2019-07-31T08:21:20.278Z

I seem to remember they're working on maybe using "classpath jars"

carkh 2019-07-31T08:21:53.278500Z

that's another workaround, but this one may be a definitive solution

carkh 2019-07-31T08:22:40.279Z

my own solution is : don't use so many libraries !

carkh 2019-07-31T08:23:11.279400Z

we're starting to look like the npm ecosystem =)

carkh 2019-07-31T08:23:58.279800Z

@sogaiu thanks for your continued testing

2019-07-31T08:25:28.280300Z

thanks for the hints and your continued efforts on this project 🙂

carkh 2019-07-31T08:29:07.281300Z

1) i don't know how to make the file output any different, I'll look into it at some point

carkh 2019-07-31T08:30:43.282300Z

i'll add a script windows side to build the installer

carkh 2019-07-31T08:37:56.283400Z

@sogaiu right click in the detail window, a menu appears with "copy details to clipboard"

2019-07-31T08:55:03.283700Z

@carkh ah great! just tried it successfully 🙂

carkh 2019-07-31T08:55:22.283900Z

nice !

2019-07-31T09:13:29.284400Z

@carkh once we are at java 9+, may be we can use the following to work around command line length limitations: https://docs.oracle.com/javase/9/tools/java.htm#JSWOR-GUID-4856361B-8BFD-4964-AE84-121F5F6CF111

carkh 2019-07-31T09:14:27.285Z

mhh, i wonder how many are below java 9 still

2019-07-31T09:16:50.285500Z

perhaps the clojure survey can give some hints on this

carkh 2019-07-31T09:17:45.285800Z

wow majority is on java 8

2019-07-31T09:19:07.286Z

yes, like 70%, right?

2019-07-31T09:19:32.286300Z

err, i guess you can answer multiple versions?

carkh 2019-07-31T09:19:52.286600Z

i don't know !

2019-07-31T09:20:17.287100Z

if we are referring to q16 -- it must be unless addition has changed 🙂

carkh 2019-07-31T09:23:14.287300Z

https://clojure.atlassian.net/browse/TDEPS-120 they're on it

2019-07-31T09:23:44.287500Z

thanks for digging that up

carkh 2019-07-31T09:27:04.288Z

i think it's possible to do something about it without even involving alex miller

carkh 2019-07-31T09:27:19.288300Z

i'll experiment with it tomorrow

2019-07-31T09:27:29.288600Z

looking forward to what you find out 🙂

carkh 2019-07-31T09:27:51.288900Z

do you have an example project ?

2019-07-31T10:00:37.289400Z

@carkh in this project: https://github.com/sogaiu/adorn -- invoking clj -A:native-image leads to problems on windows

2019-07-31T10:01:02.290100Z

setting that one up may be quite a bit of work though

carkh 2019-07-31T10:01:03.290200Z

thanks i'll try it here

2019-07-31T10:02:25.290700Z

i mentioned this before, but fwiw, here's a summary of what i needed to do for doing native-image building on windows: https://gist.github.com/sogaiu/e079cd770051685c46ab24b6658effcf

carkh 2019-07-31T10:03:05.291Z

yes i've got this in my notes

carkh 2019-07-31T10:03:41.291700Z

hum, so this exposes the classpath command line too long issue right ?

2019-07-31T10:15:30.293800Z

i get an error involving processbuilder which i believe has to do with the length limitation, but i am not sure

carkh 2019-07-31T10:19:12.294Z

allright thanks

2019-07-31T10:41:48.295300Z

@carkh here is the detailed message i get for clj -A:native-image: https://pastebin.com/XvsBfknx -- if it seems it is not the length issue, please disregard the case so you don't waste your time on it

carkh 2019-07-31T10:50:28.295900Z

allright, maybe i can make a dummy project with a big bag of libs

carkh 2019-07-31T14:34:00.297800Z

https://github.com/cark/clojure-cli-portable Now with automated building of a docker image with all the necessary tools to do cross-compilation, and the scripts to make it happen.

carkh 2019-07-31T14:34:18.298200Z

and a pretty windows installer

timgilbert 2019-07-31T17:07:53.300500Z

FWIW, I wrote that TDEPS-120 patch, but it's implemented via the ps1 side of the current Windows tools.deps stuff, so the same logic would need to be replicated inside of @carkh's nim launcher code in order to work

timgilbert 2019-07-31T17:10:31.301700Z

Er, well there's a Clojure-side tools.deps patch that would need to be merged, then the other patch is to the .ps1 file to have it use that argument.

carkh 2019-07-31T19:00:08.303400Z

@timgilbert i haven't yet fully investigated this, but wouldn't it be possible to leave tools.deps work as usual and only build the jar (on windows only) depending on the size of the cp file ?

carkh 2019-07-31T19:00:32.303800Z

from the external tool i mean

carkh 2019-07-31T19:00:38.304Z

ps1 or otherwise

timgilbert 2019-07-31T19:09:57.305Z

It would be possible, but the Clojure-side patch in the tdeps-120 ticket has it generating the pathing jar on the clojure side and then keeping it around as part of the classpath cache

timgilbert 2019-07-31T19:10:58.306300Z

Alternately you could manage that on the nim / <thing that calls tools.deps> side of things, but it made more sense to me to keep it inside of tools.deps

timgilbert 2019-07-31T19:11:28.306900Z

But yeah, you could manage it externally too

carkh 2019-07-31T19:11:42.307300Z

mhh i think i disagree on that, that's platform specific, and the keeping around is done by the external tool anyways

timgilbert 2019-07-31T19:12:47.308900Z

The way I came to think of it is that the function of tools.deps is basically to calculate and cache classpaths, and this is essentially just a different serialization format for classpaths along with the *.cp files

carkh 2019-07-31T19:13:17.309500Z

yes there is something to be said about that

carkh 2019-07-31T19:14:14.310Z

though we both have facilities to create zip files

carkh 2019-07-31T19:14:49.310500Z

to me the caching decisions are outside tools.Deps

carkh 2019-07-31T19:15:04.310900Z

it's just filling the data for the decision we took outside it

carkh 2019-07-31T19:15:30.311300Z

we're doing the hashing, we decide to call it

carkh 2019-07-31T19:16:07.311700Z

anyways i'll run with it later today and see how it goes

timgilbert 2019-07-31T20:00:22.312Z

Cool