Skip to content

Commit

Permalink
Use jvm options from RSC subsystem for RSC invocation (#8434)
Browse files Browse the repository at this point in the history
### Problem

Actual RSC invocation under `compile.rsc` is using `--compile-rsc-jvm-options` meant for zinc. Therefore, if security manager was involved for zinc, it could cause RSC invocation to fail like below:
```
23:53:22 [DEBUG] pants.engine.scheduler:pid=53433: computed 1 nodes in 1.325367 seconds. there are 3121 total nodes.
Error occurred during initialization of VM
                       java.lang.InternalError: Could not create SecurityManager: __shaded_by_pants__.com.company.common_internal.compile_security.CompileSecurityManager
                       	at sun.misc.Launcher.<init>(Launcher.java:103)
                       	at sun.misc.Launcher.<clinit>(Launcher.java:54)
                       	at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1451)
                       	at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1436)
```

### Solution

Introduce a separate set of jvm options for RSC Subsystem, which does not use `--compile-rsc-jvm-options`, but `--rsc-jvm-options`.
  • Loading branch information
wisechengyi authored Oct 14, 2019
1 parent 9393464 commit 7134456
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/python/pants/backend/jvm/subsystems/rsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def register_options(cls, register):

register('--native-image', fingerprint=True, type=bool,
help='Use a pre-compiled native-image for rsc. Requires running in hermetic mode')
register('--jvm-options', type=list, metavar='<option>...',
help='Run RSC with these jvm options.')

@property
def use_native_image(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,13 @@ def _runtool_hermetic(self, main, tool_name, distribution, input_digest, ctx):
tool_classpath_abs = self._rsc_classpath
tool_classpath = fast_relpath_collection(tool_classpath_abs)

jvm_options = self._jvm_options
rsc_jvm_options = Rsc.global_instance().get_options().jvm_options

if self._rsc.use_native_image:
#jvm_options = []
if jvm_options:
if rsc_jvm_options:
raise ValueError(
"`{}` got non-empty jvm_options when running with a graal native-image, but this is "
"unsupported. jvm_options received: {}".format(self.options_scope, safe_shlex_join(jvm_options))
"unsupported. jvm_options received: {}".format(self.options_scope, safe_shlex_join(rsc_jvm_options))
)
native_image_path, native_image_snapshot = self._rsc.native_image(self.context)
additional_snapshots = [native_image_snapshot]
Expand All @@ -623,7 +622,7 @@ def _runtool_hermetic(self, main, tool_name, distribution, input_digest, ctx):
additional_snapshots = []
initial_args = [
distribution.java,
] + self.get_options().jvm_options + [
] + rsc_jvm_options + [
'-cp', os.pathsep.join(tool_classpath),
main,
]
Expand Down

0 comments on commit 7134456

Please sign in to comment.