diff --git a/docs/build_system.md b/docs/build_system.md index 0b771d202f..98581f3898 100644 --- a/docs/build_system.md +++ b/docs/build_system.md @@ -16,9 +16,9 @@ The main solution for the second point seems a Makefile, otherwise many of the u ## General Design 1. Templates are generated by `templates/template.rb` -4. The `Makefile` compiles both `libprism.a` and `libprism.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files -5. The `Rakefile` `:compile` task ensures the above prerequisites are done, then calls `make`, - and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`), which uses `libprism.a` +2. The `Makefile` compiles both `libprism.a` and `libprism.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files +3. The `Rakefile` `:compile` task ensures the above prerequisites are done, then calls `make`, + and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`) This way there is minimal duplication, and each layer builds on the previous one and has its own responsibilities. @@ -35,14 +35,11 @@ loaded per process (i.e., at most one version of the prism *gem* loaded in a pro ### Building the prism gem by `gem install/bundle install` The gem contains the pre-generated templates. -When installing the gem, `extconf.rb` is used and that: -* runs `make build/libprism.a` -* compiles the C extension with mkmf -When installing the gem on JRuby and TruffleRuby, no C extension is built, so instead of the last step, -there is Ruby code using FFI which uses `libprism.{so,dylib,dll}` -to implement the same methods as the C extension, but using serialization instead of many native calls/accesses -(JRuby does not support C extensions, serialization is faster on TruffleRuby than the C extension). +When installing the gem on CRuby, `extconf.rb` is used and that compiles the C extension with mkmf, including both the extension files and the sources of prism itself. + +When installing the gem on JRuby and TruffleRuby, no C extension is built, so instead the `extconf.rb` runs `make build/libprism.{so,dylib,dll}`. +There is Ruby code using FFI which uses `libprism.{so,dylib,dll}` to implement the same methods as the C extension, but using serialization instead of many native calls/accesses (JRuby does not support C extensions, serialization is faster on TruffleRuby than the C extension). ### Building the prism gem from git, e.g. `gem "prism", github: "ruby/prism"` @@ -66,7 +63,7 @@ The script generates the templates when importing. Then when `mx build` builds TruffleRuby and the `prism` mx project inside, it runs `make`. -Then the `prism bindings` mx project is built, which contains the [bindings](https://github.com/oracle/truffleruby/blob/master/src/main/c/prism_bindings/src/prism_bindings.c) +Then the `prism bindings` mx project is built, which contains the [bindings](https://github.com/oracle/truffleruby/blob/vm-24.1.1/src/main/c/yarp_bindings/src/yarp_bindings.c) and links to `libprism.a` (to avoid exporting symbols, so no conflict when installing the prism gem). ### Building prism as part of JRuby diff --git a/ext/prism/extconf.rb b/ext/prism/extconf.rb index 682fdcf982..20ba28fe46 100644 --- a/ext/prism/extconf.rb +++ b/ext/prism/extconf.rb @@ -107,12 +107,6 @@ def make(env, target) # By default, all symbols are hidden in the shared library. append_cflags("-fvisibility=hidden") -# We need to link against the libprism.a archive, which is built by the -# project's `Makefile`. We'll build it if it doesn't exist yet, and then add it -# to `mkmf`'s list of local libraries. -archive_target = "build/libprism.a" -archive_path = File.expand_path("../../#{archive_target}", __dir__) - def src_list(path) srcdir = path.dup RbConfig.expand(srcdir) # mutates srcdir :-/