jakt icon indicating copy to clipboard operation
jakt copied to clipboard

selfhost/main: Create build dir before writing into it

Open miller-time opened this issue 2 years ago • 9 comments

If you do not have a build directory, the selfhost compiler gets an error if it tries to write into that directory.

➜ jakt_selfhost -b -R ~/projects/jakt/runtime hello_world.jakt
Runtime error: Error(code=2)

miller-time avatar Jul 20 '22 06:07 miller-time

the signature of mkdir on Windows is different :sweat:

miller-time avatar Jul 21 '22 06:07 miller-time

@miller-time - still seems it's not quite finding the right mkdir

sophiajt avatar Aug 04 '22 23:08 sophiajt

Hello!

One or more of the commit messages in this PR do not match the Jakt code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why. Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

BuggieBot avatar Aug 04 '22 23:08 BuggieBot

@ADKaster thanks so much for all the corrections!

rebased the branch, squashed all the messy commits...

It still says Call to unknown function: ‘mkdir’ but that's happening during this step:

[3/5] Building jakt file selfhost/main.jakt with jakt_stage0

Does that mean jakt_stage0 compiled with my changes, but for some reason jakt_stage1 doesn't work?

miller-time avatar Aug 08 '22 04:08 miller-time

Actually it means that you need to copy your runtime changes over onto bootstrap/stage0/runtime, including the prelude changes.

The stage0 compiler uses its own copy of the prelude to compile things when using the CMake build, which is distinct from the top level runtime directory used by the stage 1/2 compiler. Since we are using stage0 to compile stage1, the updated prelude functionality needs duplicated.

ADKaster avatar Aug 08 '22 04:08 ADKaster

@ADKaster yeah I just noticed that there's another runtime there (right after posting that message).

I tried copying in my runtime changes, but the error persists. Did I miss something?

miller-time avatar Aug 08 '22 04:08 miller-time

You need to do this in stages, apparently.

  1. Add new methods to prelude
  2. build compiler
  3. copy generated stage1.cpp over stage0/jakt.cpp
  4. now you can use the new methods in the compiler itself.

I don't think this is how this was intended to work, but that's the only way I could add a method to the prelude locally.

@alimpfard Why do we need to regenerate the boostrap compiler when adding methods to prelude for use in the compiler? Could we make it automatically interpret the prelude instead of comptime slapping it into the .cpp of the compiler? 🤔

ADKaster avatar Aug 25 '22 08:08 ADKaster

We could read it at runtime I guess, if we assume its location relative to the runtime dir.

alimpfard avatar Aug 25 '22 08:08 alimpfard

@ADKaster thanks, I think that got me a little closer...

jakt/build/jakt_stage1_main.cpp:55053:6: error: no matching function for call to 'mkdir'

/usr/include/x86_64-linux-gnu/sys/stat.h:389:12: note: candidate function not viable: requires 2 arguments, but 1 was provided
extern int mkdir (const char *__path, __mode_t __mode)

miller-time avatar Aug 25 '22 14:08 miller-time

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

stale[bot] avatar Jan 01 '23 12:01 stale[bot]

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

stale[bot] avatar Jan 09 '23 05:01 stale[bot]