From 6c20ac01673c66f8f93103d80451cc1366060436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Sat, 30 Jul 2022 09:00:30 -0500 Subject: [PATCH 1/6] add julia binary to Dockerfile.rootfs First step to handle [Add Julia to OmegaUp](https://github.com/omegaup/omegaup/issues/702) --- Dockerfile.rootfs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile.rootfs b/Dockerfile.rootfs index 0603e1d..77e56ba 100644 --- a/Dockerfile.rootfs +++ b/Dockerfile.rootfs @@ -60,6 +60,9 @@ RUN ls -l /usr/bin/ | grep -- '[^9] ->.*-9$' | sed -e 's@^.* \(.\+\) -> \(.\+\)- mkdir -p /opt/go && \ wget https://go.dev/dl/go1.18beta2.linux-amd64.tar.gz \ -O - | tar -xz -C /opt/go --strip-components=1 && \ + mkdir -p /opt/julia && \ + wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz \ + -O - | tar -xz -C /opt/julia --strip-components=1 && \ mkdir -p /tmp/kotlin && \ wget https://github.com/JetBrains/kotlin/releases/download/v1.6.10/kotlin-compiler-1.6.10.zip \ -O /tmp/kotlin/compiler.zip && \ From 99f6844c05e89c123c5055ddcda2d106a478c44b Mon Sep 17 00:00:00 2001 From: miguelraz Date: Sat, 30 Jul 2022 09:29:02 -0500 Subject: [PATCH 2/6] add JULIA_ROOT to mkroot --- tools/mkroot | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/mkroot b/tools/mkroot index 27f546e..0e97286 100755 --- a/tools/mkroot +++ b/tools/mkroot @@ -376,6 +376,7 @@ def _main() -> None: JS_ROOT = '/opt/nodejs/' GO_ROOT = '/opt/go/' RUST_ROOT = '/opt/rust/' + JULIA_ROOT = '/opt/julia/' RUBY_FILES = resolver.files_for('ruby', exclude_packages=COMPILER_PACKAGES) PYTHON2_FILES = resolver.files_for( @@ -429,6 +430,7 @@ def _main() -> None: root.mkdir(JS_ROOT) root.mkdir(RUST_ROOT) root.mkdir(GO_ROOT) + root.mkdir(JULIA_ROOT) # Other miscellaneous mountpoints root.mkdir('/dev/') @@ -474,6 +476,8 @@ def _main() -> None: continue root.symlink(f, os.path.join(RUBY_ROOT, f.replace('/', '_'))) + root.symlink('/usr/bin/julia', os.path.join(JULIA_ROOT, 'bin/julia')) + with Chroot( os.path.join(args.target, 'root'), '/', link=args.link) as root: install_common(root) @@ -673,6 +677,9 @@ def _main() -> None: with Chroot(os.path.join(args.target, 'root-go'), GO_ROOT, link=args.link) as root: root.copyfromhost('/opt/go', relative_to=GO_ROOT, recurse=True) + with Chroot(os.path.join(args.target, 'root-julia'), JULIA_ROOT, + link=args.link) as root: + root.copyfromhost('/opt/julia', relative_to=JULIA_ROOT, recurse=True) with Chroot(os.path.join(args.target, 'root-rust'), RUST_ROOT, link=args.link) as root: From 4784c9ce50d9b10ef47d19084ed3fab2ca7d2245 Mon Sep 17 00:00:00 2001 From: miguelraz Date: Sat, 30 Jul 2022 09:51:19 -0500 Subject: [PATCH 3/6] add julia smoketest --- smoketest/sumas.jl | 1 + smoketest/test | 1 + 2 files changed, 2 insertions(+) create mode 100644 smoketest/sumas.jl diff --git a/smoketest/sumas.jl b/smoketest/sumas.jl new file mode 100644 index 0000000..83d8c9f --- /dev/null +++ b/smoketest/sumas.jl @@ -0,0 +1 @@ +print(sum(parse.(Int, split(readline(), ' ')))) diff --git a/smoketest/test b/smoketest/test index 4aeb0dd..359c48d 100755 --- a/smoketest/test +++ b/smoketest/test @@ -41,6 +41,7 @@ _LANGUAGES = [ 'kj', 'kp', 'cs', + 'jl', ] _EXTENSIONS = { 'c11-gcc': 'c', From 8207e50577d3bb6d75f10cbc4611b57109538f66 Mon Sep 17 00:00:00 2001 From: miguelraz Date: Sat, 30 Jul 2022 09:54:45 -0500 Subject: [PATCH 4/6] add julia enum to args.rs --- src/args.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/args.rs b/src/args.rs index 241fa0a..3564d31 100644 --- a/src/args.rs +++ b/src/args.rs @@ -41,6 +41,8 @@ pub enum Language { #[clap(name = "rs")] Rust, Go, + #[clap(name = "jl")] + Julia, #[clap(name = "js")] JavaScript, #[clap(name = "kj")] From 9a8b1b14bc58e02eb36317786c17c18e53507d3e Mon Sep 17 00:00:00 2001 From: miguelraz Date: Sat, 30 Jul 2022 10:07:45 -0500 Subject: [PATCH 5/6] add julia match arm to options.rs --- src/jail/options.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/jail/options.rs b/src/jail/options.rs index 973b9c1..839ea86 100644 --- a/src/jail/options.rs +++ b/src/jail/options.rs @@ -14,6 +14,7 @@ use crate::args; const DEFAULT_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 16 * 1024 * 1024; const RUBY_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 56 * 1024 * 1024; const GO_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 512 * 1024 * 1024; +const JULIA_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 512 * 1024 * 1024; // These are obtained by running an "empty" and measuring // its memory consumption, as reported by omegajail. @@ -686,6 +687,21 @@ impl JailOptions { seccomp_profile_name = String::from("go"); execve_args.extend([format!("./{}", args.run_target)]); } + args::Language::Julia => { + extra_memory_size_in_bytes = JULIA_EXTRA_MEMORY_SIZE_IN_BYTES; + seccomp_profile_name = String::from("jl"); + mounts.push(MountArgs { + source: Some(root.join("root-julia")), + target: rootfs.join("opt/julia"), + fstype: None, + flags: MsFlags::MS_BIND | MsFlags::MS_RDONLY, + data: None, + }); + execve_args.extend([ + String::from("/usr/bin/julia"), + format!("{}.jl", args.run_target), + ]); + } args::Language::JavaScript => { seccomp_profile_name = String::from("js"); mounts.push(MountArgs { From 02107531a719f732fc8fc5c9893ac02ca4c450fc Mon Sep 17 00:00:00 2001 From: miguelraz Date: Tue, 2 Aug 2022 23:09:30 -0500 Subject: [PATCH 6/6] add missing Julia match arm --- src/jail/options.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/jail/options.rs b/src/jail/options.rs index 839ea86..53b63e4 100644 --- a/src/jail/options.rs +++ b/src/jail/options.rs @@ -483,6 +483,22 @@ impl JailOptions { ]); execve_args.extend(compile_sources.iter().map(|s| s.clone())); } + args::Language::Julia => { + seccomp_profile_name = String::from("julia"); + mounts.push(MountArgs { + source: Some(root.join("root-julia")), + target: rootfs.join("opt/julia"), + fstype: None, + flags: MsFlags::MS_BIND | MsFlags::MS_RDONLY, + data: None, + }); + execve_args.extend([ + String::from("/opt/go/bin/julia"), + String::from("-e"), + args.compile_target.clone(), + ]); + execve_args.extend(compile_sources.iter().map(|s| s.clone())); + } args::Language::JavaScript => { seccomp_profile_name = String::from("js"); mounts.push(MountArgs {