@@ -1991,6 +1991,47 @@ def getArchivableResults(self, use_relpath=True, single=False):
1991
1991
def is_skipped (self ):
1992
1992
return _skip_libraries (self .native_image_config )
1993
1993
1994
+ class PolyglotIsolateLibrary (GraalVmLibrary ):
1995
+ """
1996
+ A native image project dedicated to constructing a language polyglot isolate library.
1997
+ Despite being built upon the component supertype, it operates independently of the component system
1998
+ and native-image macros. Its configuration relies solely on the module path and META-INF/native-image
1999
+ configuration files. Instances are instantiated by mx_truffle::register_polyglot_isolate_distributions
2000
+ when a language dynamically registers a polyglot isolate distribution.
2001
+ """
2002
+ def __init__ (self , target_suite , language , deps , build_args , ** kw_args ):
2003
+ library_config = mx_sdk .LanguageLibraryConfig (
2004
+ jar_distributions = deps ,
2005
+ build_args = [],
2006
+ build_args_enterprise = build_args ,
2007
+ language = language ,
2008
+ )
2009
+ super (PolyglotIsolateLibrary , self ).__init__ (None , f'{ language } .isolate.image' ,
2010
+ list (deps ), library_config , ** kw_args )
2011
+ self .suite = target_suite
2012
+ self .dir = target_suite .dir
2013
+
2014
+
2015
+ def getBuildTask (self , args ):
2016
+ svm_support = _get_svm_support ()
2017
+ assert svm_support .is_supported (), "Needs svm to build " + str (self )
2018
+ if not self .is_skipped ():
2019
+ return PolyglotIsolateLibraryBuildTask (self , args , svm_support )
2020
+ else :
2021
+ return mx .NoOpTask (self , args )
2022
+
2023
+ def getArchivableResults (self , use_relpath = True , single = False ):
2024
+ for e in super (PolyglotIsolateLibrary , self ).getArchivableResults (use_relpath = use_relpath , single = single ):
2025
+ yield e
2026
+ if single :
2027
+ return
2028
+ output_dir = dirname (self .output_file ())
2029
+ resources_dir = join (output_dir , 'resources' )
2030
+ if exists (resources_dir ):
2031
+ yield resources_dir , 'resources'
2032
+
2033
+ def is_skipped (self ):
2034
+ return False
1994
2035
1995
2036
class GraalVmMiscLauncher (GraalVmLauncher ): # pylint: disable=too-many-ancestors
1996
2037
def __init__ (self , component , native_image_config , stage1 = False , ** kw_args ):
@@ -2440,6 +2481,32 @@ class GraalVmLibraryBuildTask(GraalVmSVMNativeImageBuildTask):
2440
2481
pass
2441
2482
2442
2483
2484
+ class PolyglotIsolateLibraryBuildTask (GraalVmLibraryBuildTask ):
2485
+ """
2486
+ A PolyglotIsolateLibrary build task building a language polyglot isolate library.
2487
+ Despite being built upon the component supertype, it operates independently of the component system
2488
+ and native-image macros. Its configuration relies solely on the module path and META-INF/native-image
2489
+ configuration files.
2490
+ """
2491
+ def get_build_args (self ):
2492
+ project = self .subject
2493
+ target = project .native_image_name [:- len (_lib_suffix )]
2494
+ build_args = [
2495
+ '-EJVMCI_VERSION_CHECK' , # Propagate this env var when running native image from mx
2496
+ '--parallelism=' + str (self .parallelism ),
2497
+ '--shared' ,
2498
+ '-o' ,
2499
+ target ,
2500
+ '--features=com.oracle.svm.enterprise.truffle.PolyglotIsolateGuestFeature' ,
2501
+ '-H:APIFunctionPrefix=truffle_isolate_' ,
2502
+ ] + svm_experimental_options ([
2503
+ '-H:+BuildOutputPrefix' ,
2504
+ '-H:+GenerateBuildArtifactsFile' , # generate 'build-artifacts.json'
2505
+ ]) + mx .get_runtime_jvm_args (self .subject .native_image_jar_distributions ) + \
2506
+ project .native_image_config .build_args + project .native_image_config .build_args_enterprise
2507
+ return build_args
2508
+
2509
+
2443
2510
class JmodModifier (mx .Project ):
2444
2511
def __init__ (self , jmod_file , library_projects , jimage_project , ** kw_args ):
2445
2512
"""
@@ -3491,7 +3558,6 @@ def register_main_dist(dist, label):
3491
3558
else :
3492
3559
with_non_rebuildable_configs = True
3493
3560
for library_config in _get_library_configs (component ):
3494
- library_project = None
3495
3561
if with_svm :
3496
3562
library_project = GraalVmLibrary (component , GraalVmNativeImage .project_name (library_config ), [], library_config )
3497
3563
register_project (library_project )
@@ -3509,29 +3575,6 @@ def register_main_dist(dist, label):
3509
3575
register_project (launcher_project )
3510
3576
polyglot_config_project = PolyglotConfig (component , library_config )
3511
3577
register_project (polyglot_config_project )
3512
- if with_svm and library_config .isolate_library_layout_distribution and not library_project .is_skipped () and has_component ('tfle' , stage1 = True ):
3513
- # Create a layout distribution with the resulting language library that can be consumed into the
3514
- # isolate resources jar distribution,
3515
- resource_base_folder = f'META-INF/resources/engine/{ library_config .language } -isolate/<os>/<arch>/libvm'
3516
- attrs = {
3517
- 'description' : f'Contains { library_config .language } language library resources' ,
3518
- 'hashEntry' : f'{ resource_base_folder } /sha256' ,
3519
- 'fileListEntry' : f'{ resource_base_folder } /files' ,
3520
- 'maven' : False ,
3521
- }
3522
- register_distribution (mx .LayoutDirDistribution (
3523
- suite = _suite ,
3524
- name = library_config .isolate_library_layout_distribution ['name' ],
3525
- deps = [],
3526
- layout = {
3527
- f'{ resource_base_folder } /' : f'dependency:{ library_project .name } '
3528
- },
3529
- path = None ,
3530
- platformDependent = True ,
3531
- theLicense = None ,
3532
- platforms = library_config .isolate_library_layout_distribution ['platforms' ],
3533
- ** attrs
3534
- ))
3535
3578
if isinstance (component , mx_sdk .GraalVmLanguage ) and component .support_distributions :
3536
3579
ni_resources_components = dir_name_to_ni_resources_components .get (component .dir_name )
3537
3580
if not ni_resources_components :
0 commit comments