Skip to content

Build PCRE2 with JIT mode enabled on mac#232

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
Blacksmoke16:pcre2-jit-macos
Mar 20, 2023
Merged

Build PCRE2 with JIT mode enabled on mac#232
straight-shoota merged 1 commit intocrystal-lang:masterfrom
Blacksmoke16:pcre2-jit-macos

Conversation

@Blacksmoke16
Copy link
Member

  • Build PCRE2 with JIT mode enabled on mac (13.2.1)
  • Drop support for OSX < 11.0
  • Add omnibus/vendor to .gitignore
$ ruby --version
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-darwin22]

Omnibus successfully built PCRE2 on my mac with this change:

[Builder: pcre2] I | 2023-03-17T13:13:05-04:00 |   PKG_CONFIG_PATH="/opt/crystal/embedded/lib/pkgconfig"
[Builder: pcre2] I | 2023-03-17T13:13:05-04:00 | $ ./configure --prefix=/opt/crystal/embedded --disable-cpp --disable-shared --enable-unicode-properties --enable-utf --enable-jit
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 | Execute: `./configure --prefix=/opt/crystal/embedded --disable-cpp --disable-shared --enable-unicode-properties --enable-utf --enable-jit': 27.8581s
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 | Environment:
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   CFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC -arch arm64 -arch x86_64"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   CPPFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC "
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   CXXFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC -arch arm64 -arch x86_64"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   LDFLAGS="-Wl,-rpath,/opt/crystal/embedded/lib -L/opt/crystal/embedded/lib"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   LD_RUN_PATH="/opt/crystal/embedded/lib"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   OMNIBUS_INSTALL_DIR="/opt/crystal"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   PATH="<redacted>"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 |   PKG_CONFIG_PATH="/opt/crystal/embedded/lib/pkgconfig"
[Builder: pcre2] I | 2023-03-17T13:13:33-04:00 | $ make -j 17
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | Execute: `make -j 17': 24.9378s
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | Environment:
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   CFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC -arch arm64 -arch x86_64"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   CPPFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC "
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   CXXFLAGS="-I/opt/crystal/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector -DMAC_OS_X_VERSION_MIN_REQUIRED=110000 -fPIC -arch arm64 -arch x86_64"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   LDFLAGS="-Wl,-rpath,/opt/crystal/embedded/lib -L/opt/crystal/embedded/lib"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   LD_RUN_PATH="/opt/crystal/embedded/lib"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   OMNIBUS_INSTALL_DIR="/opt/crystal"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   PATH="<redacted>"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 |   PKG_CONFIG_PATH="/opt/crystal/embedded/lib/pkgconfig"
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | $ make install
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | Execute: `make install': 0.5981s
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | Build pcre2: 53.3974s
[Builder: pcre2] I | 2023-03-17T13:13:58-04:00 | Finished build

But the build ultimately failed, for I'd assume due to an unrelated/known issue:

Output:

    ./bin/crystal --release --stats -o /opt/crystal/embedded/bin/crystal src/compiler/crystal.cr
Using compiled compiler at .build/crystal

Error:

    Error: unknown command: --release
make[1]: *** [/opt/crystal/embedded/bin/crystal] Error 1

Resolves #228

Drop support for OSX < 11.0
@straight-shoota
Copy link
Member

CI workflow run: https://app.circleci.com/pipelines/github/crystal-lang/crystal/11511/workflows/7b791aaa-73cf-4e89-be65-5b25bb3d10ec

@straight-shoota
Copy link
Member

@Blacksmoke16 Have you tested the artifacts from the CI workflow to ensure JIT compilation is working?

@Blacksmoke16
Copy link
Member Author

Seems like it is:

jit_enabled = uninitialized UInt32

LibPCRE2.config LibPCRE2::CONFIG_JIT, pointerof(jit_enabled)

pp jit_enabled
$ ./crystal-ci-update-distribution-scripts-pcre2-jit-dev-1/bin/crystal run -Duse_pcre2 test.cr
1

While before from https://app.circleci.com/pipelines/github/crystal-lang/crystal/11516/workflows/1be479c4-9fa7-4c5c-bed0-6cc779c784c6/jobs/75135, it is:

$ ./crystal-1.8.0-dev-1/bin/crystal run test.cr
0

Also I can't remember if its expected or not, but none of the 1.7.x tarballs have pcre2-8 within the embedded/lib directory so it fails when using -Duse_pcre2, so technically you couldn't use it to test at all.

@straight-shoota
Copy link
Member

Thanks, then we can merge this.

Also I can't remember if its expected or not, but none of the 1.7.x tarballs have pcre2-8 within the embedded/lib directory so it fails when using -Duse_pcre2, so technically you couldn't use it to test at all.

Yes, that's expected. You need to install it explicitly.

@straight-shoota straight-shoota merged commit eb89bd3 into crystal-lang:master Mar 20, 2023
@Blacksmoke16 Blacksmoke16 deleted the pcre2-jit-macos branch March 20, 2023 13:53
@Blacksmoke16
Copy link
Member Author

Blacksmoke16 commented Mar 20, 2023

Yes, that's expected. You need to install it explicitly.

But the catch is I do have pcre2 installed explicitly, but won't it not be able to find it due to the lib path pointing at that single directly that doesn't have it?

@straight-shoota
Copy link
Member

CRYSTAL_LIBRARY_PATH is not exclusive. It goes on top of any other library paths configured with the system/linker. As long as ld is able to find the library somewhere, you should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable PCRE2 JIT on pre-built macos binaries

2 participants