soegaard2
2017-7-7 19:15:46

I need a hint. I’d like to experiment with linklets. I have compiled both chez and racket7 from mflatt’s repos. It seems to work. In the expander/ directory, racket run.rkt and racket bootstrap-demo.rkt works.


soegaard2
2017-7-7 19:16:21

I can’t get racket run.rkt -c <dir> —linklets -l <module-path> to work though.


soegaard2
2017-7-7 19:17:29

I made a directory l to store the linklets. Wrote a fact.rkt and attempted to run: ../racket7/racket/bin/racket ../racket7/pkgs/expander/run.rkt -c l —linklets -l fact.rkt


soegaard2
2017-7-7 19:17:41

I get: standard-module-name-resolver: collection not found for module path: (lib “fact.rkt”) collection: “mzlib”


mflatt
2017-7-7 19:52:18

@soegaard2 You’d get the same error with racket -l fact.rkt. Try ... -t fact.rkt


soegaard2
2017-7-7 19:53:22

mbp:ur soegaard$ ../racket7/racket/bin/racket ../racket7/pkgs/expander/run.rkt -c l —linklets -t fact.rkt compile: /Users/soegaard/Dropbox/GitHub/racket7/ur/fact.rkt …during /Users/soegaard/Dropbox/GitHub/racket7/ur/fact.rkt… standard-module-name-resolver: collection not found for module path: (submod racket/base reader) collection: “racket” in collection directories: context…:


mflatt
2017-7-7 19:53:22

You usually don’t have to use -t, and just write racket fact.rkt, so that’s probably the confusion


mflatt
2017-7-7 19:54:06

Does ... -l racket/base work?


soegaard2
2017-7-7 19:54:30

racket -t fact.rkt works (but I was interested in the linklets)


mflatt
2017-7-7 19:55:16

Looking more, I think I’ve probably changed things so that you need -k for now


soegaard2
2017-7-7 19:56:08

-k ?


mflatt
2017-7-7 19:56:23

../racket7/racket/bin/racket ../racket7/pkgs/expander/run.rkt -k ../racket7/racket -c l --linklets -t fact.rkt


soegaard2
2017-7-7 19:59:09

Okay. That compiles and stores a load of tiles in l/ . They are have hashes as names and seems to have a binary encoding?


mflatt
2017-7-7 20:00:02

Yes, they’re bytecode unless you also use -s


soegaard2
2017-7-7 20:03:19

The -s flag doesn’t seem to affect the files. (I deleted l/ before running with the -s flag)


mflatt
2017-7-7 20:04:09

I’m stumped. The file names are still hashes, but the content shouldn’t be bytecode


soegaard2
2017-7-7 20:05:10

../racket7/racket/bin/racket ../racket7/pkgs/expander/run.rkt -s -k ../racket7/racket -c l —linklets -t fact.rkt


soegaard2
2017-7-7 20:07:01

For context: I am working on a Racket to JavaScript compiler. The next natural step is to add modules. So, as this is a long term project, I thought it would be a good idea to look into linklets.


samth
2017-7-7 20:07:29

@soegaard2 ooh!


samth
2017-7-7 20:07:36

you should definitely look into linklets


soegaard2
2017-7-7 20:08:46

Good to hear.


samth
2017-7-7 20:10:20

one thing you might be interested in, although it’s not directly what you want longest-term, is the linklet extractor, which can take an (almost) arbitrary racket source file and produce a 0-dependency single linklet as output


notjack
2017-7-7 20:10:54

@samth out of curiosity, why “almost”? what sort of source files does it not handle?


samth
2017-7-7 20:11:51

It makes a few assumptions, and I don’t know that it handles all of racket — the relevant linklets all use #lang racket/base


soegaard2
2017-7-7 20:12:08

The linklet extractor sounds as an ideal starting point.


samth
2017-7-7 20:12:14

but @mflatt might be able to be precise about the limitations


samth
2017-7-7 20:12:27

also, it definitely doesn’t work if you use dynamic-require


mflatt
2017-7-7 20:16:26

the extractor doesn’t work on a module whose run-time code references something implemented by the expander


mflatt
2017-7-7 20:16:44

So it doesn’t work with #lang racket eval or #lang racket #'x


mflatt
2017-7-7 20:16:57

But #lang racket (begin-for-syntax eval) is ok


notjack
2017-7-7 20:17:16

so no run-time syntax objects allowed? makes sense


mflatt
2017-7-7 20:17:45

right


mflatt
2017-7-7 20:18:49

I should have written #lang racket/base in those examples. I don’t think #lang racket could work


notjack
2017-7-7 20:20:04

would there be a point to a #lang racket/something which is like base but omits everything that’s implemented by the expander?


mflatt
2017-7-7 20:23:08

I don’t know. The extractor is primarily meant to extract the expander itself and a couple of other layers, but it may be useful for more in the end


samth
2017-7-7 20:23:28

The extraction mechanism is really just a bootstrapping thing currently — I suggested it to @soegaard2 because it’s probably a good place to start


mflatt
2017-7-7 20:29:27

@soegaard2 I remember now: -s only works with “bootstrap-run.rkt” instead of “run.rkt”


soegaard2
2017-7-7 20:29:47

Ok. I’ll try that!


mflatt
2017-7-7 20:30:57

I’m seeing a segfault, which I’ll investigate


soegaard2
2017-7-7 20:32:07

Ditto. But the cache now contains linklets in source format.


mflatt
2017-7-7 20:39:46

repair pushed


soegaard2
2017-7-7 20:39:59

fast as always!


soegaard2
2017-7-7 20:54:04

Works as a charm.