Skip to content
Dong-Eon Goo edited this page Dec 22, 2021 · 25 revisions

How to build native image

For Windows

  • Download GraalVM Community Edition 21.0.0.2
    • Latest version is 21.3.0, but I didn't tested it yet.
  • Install native-image
    • gu install native-image
  • Open x64 Native Tools Command Prompt for VS 2019
  • Build PE binary using GraalVM Native Image
    • native-image -jar log4j2-scanner-2.3.2.jar log4j2-scan-2.3.2 -H:-CheckToolchain -H:ReflectionConfigurationFiles=scanner.json
    • Added ReflectionConfigurationFiles option to allow reparse point related reflection.

For Linux

  • Install glibc-static
    • yum install glibc-static
  • Set environment variables
    • export PATH=/path/to/graalvm-ce/graalvm-ce-java11-21.0.0.2/bin:$PATH
      export JAVA_HOME=/path/to/graalvm-ce/graalvm-ce-java11-21.0.0.2/
      
  • Build elf binary using GraalVM Native Image
    • native-image --static -jar log4j2-scanner-2.3.2.jar log4j2-scan -H:-CheckToolchain -H:+AllowIncompleteClasspath
    • Added AllowIncompleteClasspath option to ignore windows specific reflection.

For Mac OS

  • Build Mach-O binary using GraalVM Native Image

    • native-image -jar log4j2-scanner-2.3.2.jar log4j2-scan -H:-CheckToolchain -H:+AllowIncompleteClasspath
    • Added AllowIncompleteClasspath option to ignore windows specific reflection.
  • Codesign and Notarize binary

    • Install Xcode first. It takes too long time.
    • Generate App-Specific Password from https://appleid.apple.com/
    • Generate Developer-ID Application Certificate from https://developer.apple.com/
    • Codesign the binary codesign --options=runtime -s 'Developer ID Application' log4j2-scan codesign -dv log4j2-scan
    • Zip the binary zip log4j2-scan.zip log4j2-scan
    • Retrive your ProviderShortname AC_USERNAME is apple id AC_PASSWORD is App-Specific Password xcrun altool --list-providers -u "AC_USERNAME" -p "AC_PASSWORD"
    • Notarize the binary
              --primary-bundle-id "com.example.ote.zip" \
              --username "AC_USERNAME" \
              --password "AC_PASSWORD" \
              --asc-provider <ProviderShortname> \
              --file log4j2-scan.zip```
      
    • Check natarization status
      ```xcrun altool --notarization-info "RequestUUID" -u "AC_USERNAME"````
      
Clone this wiki locally