diff --git a/.ci/lib/stage-build-test-only.jenkinsfile b/.ci/lib/stage-build-test-only.jenkinsfile new file mode 100644 index 0000000000..3c6770df1f --- /dev/null +++ b/.ci/lib/stage-build-test-only.jenkinsfile @@ -0,0 +1,23 @@ +stage('build') { + try { + sh ''' + meson setup build/ \ + --werror \ + --prefix="$PREFIX" \ + --buildtype="$BUILDTYPE" \ + -Dskeleton=disabled \ + -Ddirect=disabled \ + -Dsgx=disabled \ + -Dtests=enabled \ + $MESON_OPTIONS + ninja -vC build/ + ''' + } finally { + archiveArtifacts ''' + build/meson-logs/**/*, + ''' + } + + sh 'rm -rf build' + sh 'git clean -Xf subprojects' +} diff --git a/.ci/linux-tests-only.jenkinsfile b/.ci/linux-tests-only.jenkinsfile new file mode 100644 index 0000000000..231d59f9e3 --- /dev/null +++ b/.ci/linux-tests-only.jenkinsfile @@ -0,0 +1,15 @@ +node('nonsgx_slave') { + checkout scm + + load '.ci/lib/config-docker.jenkinsfile' + docker.build( + "local:${env.BUILD_TAG}", + '-f .ci/ubuntu20.04.dockerfile .' + ).inside("${env.DOCKER_ARGS_COMMON} --security-opt seccomp=${env.WORKSPACE}/scripts/docker_seccomp_mar_2021.json") { + load '.ci/lib/config.jenkinsfile' + load '.ci/lib/config-clang.jenkinsfile' + + load '.ci/lib/stage-build-test-only.jenkinsfile' + # XXX: we should also run test + } +} diff --git a/libos/meson.build b/libos/meson.build index f99fa39edc..cb2f4f2be8 100644 --- a/libos/meson.build +++ b/libos/meson.build @@ -17,8 +17,10 @@ if host_machine.cpu_family() == 'x86_64' cflags_libos += ['-mfxsr', '-mxsave'] endif -subdir('include') -subdir('src') +if src_build + subdir('include') + subdir('src') +endif if enable_tests subdir('test') diff --git a/libos/test/regression/meson.build b/libos/test/regression/meson.build index c1270607e5..43bf7be896 100644 --- a/libos/test/regression/meson.build +++ b/libos/test/regression/meson.build @@ -192,20 +192,18 @@ if host_machine.cpu_family() == 'x86_64' } endif -if sgx - tests += { - 'attestation': { - # for `sgx_arch.h` - 'include_directories': include_directories('../../../pal/src/host/linux-sgx'), - 'source': [ - 'attestation.c', - '../../../pal/src/host/linux-sgx/enclave_api.S', - ], +tests += { + 'attestation': { + # for `sgx_arch.h` + 'include_directories': include_directories('../../../pal/src/host/linux-sgx'), + 'source': [ + 'attestation.c', + '../../../pal/src/host/linux-sgx/enclave_api.S', + ], - 'dependencies': mbedtls_static_dep, - }, - } -endif + 'dependencies': mbedtls_static_dep, + }, +} install_dir = pkglibdir / 'tests' / 'libos' / 'regression' diff --git a/meson.build b/meson.build index 329272b844..b26dc60245 100644 --- a/meson.build +++ b/meson.build @@ -23,9 +23,9 @@ project( # We can't change to c23 for any supported versions yet (requires at # least gcc 14). if meson.get_compiler('c').has_argument('-std=c23') - add_project_arguments('-std=c23', language: 'c') + add_project_arguments('-std=c23', language: 'c') elif meson.get_compiler('c').has_argument('-std=c2x') - add_project_arguments('-std=c2x', language: 'c') + add_project_arguments('-std=c2x', language: 'c') endif # we need this subdir() early, because we need scripts defined there for setting up global vars @@ -51,6 +51,8 @@ vtune = get_option('vtune') == 'enabled' enable_libgomp = get_option('libgomp') == 'enabled' enable_tests = get_option('tests') == 'enabled' +src_build = skeleton or direct or sgx + cc = meson.get_compiler('c') host_has_glibc = cc.get_define('__GLIBC__', prefix: '#include ') != '' objcopy = find_program('objcopy') @@ -230,19 +232,24 @@ endif # # Dependencies # +if src_build + tomlc99_proj = subproject('tomlc99-208203af46bdbdb29ba199660ed78d09c220b6c5') + tomlc99_dep = tomlc99_proj.get_variable('tomlc99_dep') + tomlc99_src = tomlc99_proj.get_variable('tomlc99_src') -tomlc99_proj = subproject('tomlc99-208203af46bdbdb29ba199660ed78d09c220b6c5') -tomlc99_dep = tomlc99_proj.get_variable('tomlc99_dep') -tomlc99_src = tomlc99_proj.get_variable('tomlc99_src') - -uthash_dep = subproject('uthash-2.1.0').get_variable('uthash_dep') + uthash_dep = subproject('uthash-2.1.0').get_variable('uthash_dep') +endif +# Build Mbed TLS even if !src_build because some tests (attestation tests) +# require it. mbedtls_proj = subproject('mbedtls-3.6.0') mbedtls_static_dep = mbedtls_proj.get_variable('mbedtls_static_dep') mbedtls_pal_dep = mbedtls_proj.get_variable('mbedtls_pal_dep') -curl_proj = subproject('curl-8.8.0') -cjson_proj = subproject('cJSON-1.7.12') +if src_build + curl_proj = subproject('curl-8.8.0') + cjson_proj = subproject('cJSON-1.7.12') +endif if sgx # XXX: do not call subproject() from under "if sgx" conditional, because it @@ -288,16 +295,22 @@ endif # The compilation # -subdir('common') -subdir('pal') +if src_build + subdir('common') + subdir('pal') +endif subdir('libos') subdir('python') -subdir('tools') +if src_build + subdir('tools') +endif -if get_option('libc') == 'glibc' - subproject('glibc-2.39-1') -elif get_option('libc') == 'musl' - subproject('musl-1.2.4') +if src_build + if get_option('libc') == 'glibc' + subproject('glibc-2.39-1') + elif get_option('libc') == 'musl' + subproject('musl-1.2.4') + endif endif if enable_libgomp diff --git a/pal/meson.build b/pal/meson.build index 8c5799ac8f..6004a752fc 100644 --- a/pal/meson.build +++ b/pal/meson.build @@ -1,8 +1,10 @@ -subdir('include') -subdir('src') +if src_build + subdir('include') + subdir('src') -if enable_tests - subdir('regression') + if enable_tests + subdir('regression') + endif endif if debug diff --git a/python/graminelibos/__init__.py b/python/graminelibos/__init__.py index a96d57e768..5c19e7ddfc 100644 --- a/python/graminelibos/__init__.py +++ b/python/graminelibos/__init__.py @@ -6,7 +6,8 @@ _CONFIG_PKGLIBDIR = '@PKGLIBDIR@' _CONFIG_LIBDIR = '@LIBDIR@' _CONFIG_SYSLIBDIR = '@SYSLIBDIR@' -_CONFIG_SGX_ENABLED = '@SGX_ENABLED@' == '1' +_CONFIG_SGX_ENABLED = _os.path.exists('@PKGLIBDIR@/sgx/libpal.so') + if __version__.startswith('@') and not _os.getenv('GRAMINE_IMPORT_FOR_SPHINX_ANYWAY') == '1': raise RuntimeError( diff --git a/subprojects/packagefiles/mbedtls/meson.build b/subprojects/packagefiles/mbedtls/meson.build index bc084767ef..104a3260a3 100644 --- a/subprojects/packagefiles/mbedtls/meson.build +++ b/subprojects/packagefiles/mbedtls/meson.build @@ -58,7 +58,7 @@ pkgconfig.generate( ], ) -if get_option('libc') == 'glibc' and host_has_glibc +if get_option('libc') == 'glibc' and host_has_glibc and src_build foreach output : mbedtls_libs_output meson.add_install_script('/bin/sh', '-c', ('ln -sf ../../../@0@ ' +