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

add JuliaLang #32

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile.rootfs
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
1 change: 1 addition & 0 deletions smoketest/sumas.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print(sum(parse.(Int, split(readline(), ' '))))
1 change: 1 addition & 0 deletions smoketest/test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ _LANGUAGES = [
'kj',
'kp',
'cs',
'jl',
]
_EXTENSIONS = {
'c11-gcc': 'c',
Expand Down
2 changes: 2 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub enum Language {
#[clap(name = "rs")]
Rust,
Go,
#[clap(name = "jl")]
Julia,
#[clap(name = "js")]
JavaScript,
#[clap(name = "kj")]
Expand Down
16 changes: 16 additions & 0 deletions src/jail/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how was this measured?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took the largest I saw.
I'm guessing it will need tweaking.


// These are obtained by running an "empty" and measuring
// its memory consumption, as reported by omegajail.
Expand Down Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like the seccomp files are missing from this change! can they be added?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I don't know what those are though 😅

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 {
Expand Down
7 changes: 7 additions & 0 deletions tools/mkroot
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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/')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down