MPLLang / mpl

The MaPLe compiler for efficient and scalable parallel functional programming
Other
306 stars 18 forks source link

Unable to build with MLton with MPL installed #170

Open hai-nguyen-van opened 1 year ago

hai-nguyen-van commented 1 year ago

I am unable to build a project with MLton after MPL has been installed using its make install. I need to build this project using make hmc and I face the following errors:

mlton -verbose 1 -output hmc src/hmc/hmc.mlb
MLton 20210117.153942-gb1f1f0f09-dirty starting
   Compile SML starting
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 181.13-182.43.
  Invalid type for _import.
    C_Pthread_Key.t * 'a array -> unit
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 193.13-193.87.
  Unknown primitive: Array_update_noWriteBarrier.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 196.13-196.68.
  Unknown primitive: Ref_assign_noWriteBarrier.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 199.13-199.76.
  Unknown primitive: Array_sub_noReadBarrier.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 202.13-202.59.
  Unknown primitive: Ref_deref_noReadBarrier.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 215.9-215.48.
  Unknown primitive: Ref_cas.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 218.9-218.67.
  Unknown primitive: Array_cas.
Error: $(SML_LIB)/basis/primitive/prim-mlton.sml 356.9-357.50.
  Invalid type for _import.
    'a ref * 'b ref * 'c ref * thread -> bool
   Compile SML reported errors in 1.55 + 0.78 (34% GC)
MLton 20210117.153942-gb1f1f0f09-dirty reported errors in 1.55 + 0.78 (34% GC)
make: *** [Makefile:34: hmc] Error 1

I have discussed with @MatthewFluet about a very similar issue (https://github.com/MLton/mlton/issues/488#issuecomment-1397036002) who seems to indicate that the problem comes from MPL rather than MLton. Interestingly, I am able to build project using the root Docker shwestrick/mpl... so I don't really understand 🤔

shwestrick commented 1 year ago

Ah, I have a suspicion this is because the MPL install scripts are only slightly modified from MLton's, so it might be overwriting some of the local install of MLton when doing make install.

Perhaps it's enough to install MPL somewhere else, such as make install PREFIX=/opt/mpl?

Alternatively, you could try out mpl-switch, which is a small python script to help manage local installs of MPL. It installs to a directory ~/.mpl/ and lets you have multiple versions of MPL installed simultaneously, so it should work with any local install of MLton you have, too.