roc icon indicating copy to clipboard operation
roc copied to clipboard

Update cli for new platform host build process

Open lukewilliamboswell opened this issue 1 year ago • 2 comments

zulip discussion

Currently, when you run roc run with a local platform, roc re-builds the platform each time, and links the application to produce the executable. We would like to remove this relationship, so that roc cli does not need to be aware of the platform host build toolchain.

The platform will be solely responsible for building the files it needs and provides roc prebuilt host files for roc to work with. E.g. legacy linker e.g. libapp.so, surgical linker e.g. linux-x64.rh and metadata_linux-x64.rm.

To implement this change we should first update the supported platforms (in examples, roc-lang/basic-cli and roc-lang/webserver) to have a build script, before we can remove the relevant functionality from the cli.

The scope of this task is to

  • update platforms with a build script that produces a prebuilt-binary for the native/current target (for working with platform locally and not via a URL package)
  • update cli so that the default is for roc to link against the pre-built binary when using roc run etc and does not try to re-build the platform.
  • cleanup any unused code as roc is no longer responsible for building platforms

lukewilliamboswell avatar Jan 22 '24 08:01 lukewilliamboswell

Also see this zulip chat

@rtfeldman said:

  • we always build applications from a precompiled host, so no more 🔨 Rebuilding platform... message
  • this means that the individual platform needs to have a script which does the relevant parts of "rebuilding platform" for its host
  • the goal of the platform build script should be outputting a Roc precompiled host file

@brian-carroll siad:

OK so we should start recommending that to people who are having build problems.

  1. Use ROC_PRINT_BUILD_COMMANDS=1 roc build my-program.roc to see the commands that Roc is using to build your host language code.
  2. Extract those commands into your favourite build system, like a build.zig or a build.rs or a makefile.
  3. From then on, use roc build my-program.roc --precompiled-host=<path> and change the commands as you see fit.

ROC_PRINT_BUILD_COMMANDS=1 will only work with a development build of the Roc compiler.

lukewilliamboswell avatar Mar 05 '24 23:03 lukewilliamboswell

Perhaps we should create a new issue that combines #6307 and this one?

Anton-4 avatar Mar 06 '24 09:03 Anton-4