Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared library build output bug #216

Closed
sgammon opened this issue Jan 1, 2024 · 0 comments · Fixed by #217
Closed

Shared library build output bug #216

sgammon opened this issue Jan 1, 2024 · 0 comments · Fixed by #217
Assignees
Labels
bug Something isn't working native-image Features and issues relating to the Native Image tool
Milestone

Comments

@sgammon
Copy link
Owner

sgammon commented Jan 1, 2024

given the following on a macOS M-series machine:

load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_binary")
load("@rules_graalvm//graalvm:defs.bzl", "native_image")

kt_jvm_library(
    name = "ktlib",
    srcs = [
      "GraalVMEntry.kt",
    ],
)

native_image(
    name = "native_lib",
    deps = [":ktlib"],
    shared_library = True,
)

then:

bazel build //src/workerd/gvm:native_lib

yields:

INFO: From Native Image (fastbuild) //src/workerd/gvm:native_lib:
========================================================================================================================
GraalVM Native Image: Generating 'native_lib-bin' (shared library)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (2.8s @ 0.17GB)
 Java version: 17.0.8+9-LTS, vendor version: Oracle GraalVM 17.0.8+9.1
 Graal compiler: optimization level: b, target machine: armv8-a, PGO: off
 C compiler: wrapped_clang (null, null, 0.0.0)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
[2/8] Performing analysis...  [***]                                                                      (2.7s @ 0.44GB)
   1,777 (59.08%) of  3,008 types reachable
   1,641 (46.07%) of  3,562 fields reachable
   7,481 (35.69%) of 20,959 methods reachable
     607 types,     0 fields, and   281 methods registered for reflection
      49 types,    33 fields, and    48 methods registered for JNI access
       4 native libraries: -framework Foundation, dl, pthread, z
[3/8] Building universe...                                                                               (0.5s @ 0.44GB)
[4/8] Parsing methods...      [*]                                                                        (0.3s @ 0.32GB)
[5/8] Inlining methods...     [***]                                                                      (0.2s @ 0.51GB)
[6/8] Compiling methods...    [*]                                                                        (1.5s @ 0.51GB)
[7/8] Layouting methods...    [*]                                                                        (0.2s @ 0.31GB)
[8/8] Creating image...       [*]                                                                        (0.7s @ 0.42GB)
   1.71MB (33.35%) for code area:     4,096 compilation units
   3.19MB (62.20%) for image heap:   47,316 objects and 1 resources
 233.85kB ( 4.46%) for other data
   5.12MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
 852.68kB java.base                                          403.57kB byte[] for java.lang.String
 768.00kB svm.jar (Native Image)                             363.50kB byte[] for code metadata
  51.09kB com.oracle.svm.svm_enterprise                      317.23kB java.lang.String
  17.54kB org.graalvm.nativeimage.base                       278.23kB java.lang.Class
  16.20kB org.graalvm.sdk                                    247.81kB byte[] for general heap data
  10.61kB jdk.internal.vm.ci                                 139.03kB java.util.HashMap$Node
   4.56kB jdk.internal.vm.compiler                           111.71kB char[]
   1.76kB jdk.proxy3                                          78.80kB java.lang.Object[]
   1.72kB jdk.proxy1                                          69.41kB com.oracle.svm.core.hub.DynamicHubCompanion
  540.00B jdk.proxy2                                          67.19kB byte[] for reflection metadata
    0.00B for 0 more packages                                426.09kB for 502 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 PGO:  Use Profile-Guided Optimizations ('--pgo') for improved throughput.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
 BRPT: Try out the new build reports with '-H:+BuildReport'.
------------------------------------------------------------------------------------------------------------------------
                        0.3s (3.0% of total time) in 19 GCs | Peak RSS: 1.12GB | CPU load: 5.26
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /private/var/tmp/_bazel_sam/8cc51c405206f1802bbd06ef31694ada/sandbox/darwin-sandbox/5204/execroot/workerd/bazel-out/darwin_arm64-fastbuild/bin/src/workerd/gvm/graal_isolate.h (c_header)
 /private/var/tmp/_bazel_sam/8cc51c405206f1802bbd06ef31694ada/sandbox/darwin-sandbox/5204/execroot/workerd/bazel-out/darwin_arm64-fastbuild/bin/src/workerd/gvm/graal_isolate_dynamic.h (c_header)
 /private/var/tmp/_bazel_sam/8cc51c405206f1802bbd06ef31694ada/sandbox/darwin-sandbox/5204/execroot/workerd/bazel-out/darwin_arm64-fastbuild/bin/src/workerd/gvm/native_lib-bin.dylib (shared_library)
========================================================================================================================
Finished generating 'native_lib-bin' in 9.2s.
ERROR: /Volumes/VAULTROOM/workerd/src/workerd/gvm/BUILD.bazel:13:13: output 'src/workerd/gvm/native_lib-bin' was not created
ERROR: /Volumes/VAULTROOM/workerd/src/workerd/gvm/BUILD.bazel:13:13: Native Image (fastbuild) //src/workerd/gvm:native_lib failed: not all outputs were created or valid
Target //src/workerd/gvm:native_lib failed to build
@sgammon sgammon added bug Something isn't working native-image Features and issues relating to the Native Image tool labels Jan 1, 2024
@sgammon sgammon added this to the 1.0.0 milestone Jan 1, 2024
@sgammon sgammon self-assigned this Jan 1, 2024
sgammon added a commit that referenced this issue Jan 1, 2024
- fix: use `dylib` postfix for shared library outputs on mac
- fix: use `so` postfix for shared library outputs on linux
- fix: consolidate bin postfix `exe` with new behavior

Closes: #216
Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit that referenced this issue Jan 1, 2024
- fix: use `dylib` postfix for shared library outputs on mac
- fix: use `so` postfix for shared library outputs on linux
- fix: consolidate bin postfix `exe` with new behavior
- test: add integration test for shared libs on all platforms

Closes: #216
Signed-off-by: Sam Gammon <[email protected]>
@sgammon sgammon moved this to In Progress in GraalVM Rules for Bazel Jan 1, 2024
sgammon added a commit that referenced this issue Jan 1, 2024
- fix: use `dylib` postfix for shared library outputs on mac
- fix: use `so` postfix for shared library outputs on linux
- fix: consolidate bin postfix `exe` with new behavior
- test: add integration test for shared libs on all platforms

Closes: #216
Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit that referenced this issue Jan 1, 2024
- fix: use `dylib` postfix for shared library outputs on mac
- fix: use `so` postfix for shared library outputs on linux
- fix: consolidate bin postfix `exe` with new behavior
- test: add integration test for shared libs on all platforms

Closes: #216
Signed-off-by: Sam Gammon <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in GraalVM Rules for Bazel Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working native-image Features and issues relating to the Native Image tool
Projects
Development

Successfully merging a pull request may close this issue.

1 participant