From 4327d00dc2de1c7f9d63b11b9b7699a05d96be94 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Mon, 8 Jul 2024 20:29:30 -0400 Subject: [PATCH] debug --- Dockerfile | 17 ++++++++++------- src/compile.rs | 38 ++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70048e9..e3a21db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,13 +8,16 @@ RUN dnf install -y libasan libubsan # Precompile bits/stdc++.h: https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html # I believe flags like -Wall are ignored, but flags like -std, -O2, and -fsanitize=address must # match the flags used to precompile the header. -RUN mkdir -p /precompiled-headers/bits/stdc++.h.gch -RUN g++ -std=c++11 -O2 -o /precompiled-headers/bits/stdc++.h.gch/01 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h -RUN g++ -std=c++17 -O2 -o /precompiled-headers/bits/stdc++.h.gch/02 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h -RUN g++ -std=c++23 -O2 -o /precompiled-headers/bits/stdc++.h.gch/03 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h -RUN g++ -std=c++11 -O2 -fsanitize=address -o /precompiled-headers/bits/stdc++.h.gch/04 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h -RUN g++ -std=c++17 -O2 -fsanitize=address -o /precompiled-headers/bits/stdc++.h.gch/05 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h -RUN g++ -std=c++23 -O2 -fsanitize=address -o /precompiled-headers/bits/stdc++.h.gch/06 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN mkdir -p /var/runtime/task/precompiled-headers/bits/stdc++.h.gch +RUN g++ -std=c++11 -O2 -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/01 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN g++ -std=c++17 -O2 -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/02 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN g++ -std=c++23 -O2 -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/03 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN g++ -std=c++11 -O2 -fsanitize=address -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/04 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN g++ -std=c++17 -O2 -fsanitize=address -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/05 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h +RUN g++ -std=c++23 -O2 -fsanitize=address -o /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/06 /usr/include/c++/11/x86_64-amazon-linux/bits/stdc++.h + +# ^ this takes 0.3s to compile. However, the initial compilation can take a lot longer than 5 seconds, presumably because lambda disk read speeds are very slow. +# I think maybe we try to compile this after execution or something. RUN dnf install -y java-21-amazon-corretto-devel RUN dnf install -y time diff --git a/src/compile.rs b/src/compile.rs index 783a453..642d17d 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -49,30 +49,36 @@ pub fn compile(compile_request: CompileRequest) -> Result { "g++ -I/precompiled-headers -o {} {} program.cpp", output_file_path, compile_request.compiler_options ); + let command = format!( + "{}", + compile_request.source_code, + // "cp /var/runtime/task/precompiled-headers/bits/stdc++.h.gch/01 /tmp/01", + ); let compile_output = run_command( &command, tmp_dir.path(), CommandOptions { stdin: String::new(), - timeout_ms: 5000, + timeout_ms: 600000, }, )?; - let executable = if ExitStatus::from_raw(compile_output.exit_code).success() { - let encoded_binary = BASE64_STANDARD.encode(fs::read(output_file_path)?); - Some(match compile_request.language { - Language::Cpp => Executable::Binary { - value: encoded_binary, - }, - Language::Java21 => Executable::JavaClass { - class_name: "Main".to_string(), - value: encoded_binary, - }, - Language::Py11 => unreachable!(), - }) - } else { - Option::None - }; + // let executable = if ExitStatus::from_raw(compile_output.exit_code).success() { + // let encoded_binary = BASE64_STANDARD.encode(fs::read(output_file_path)?); + // Some(match compile_request.language { + // Language::Cpp => Executable::Binary { + // value: encoded_binary, + // }, + // Language::Java21 => Executable::JavaClass { + // class_name: "Main".to_string(), + // value: encoded_binary, + // }, + // Language::Py11 => unreachable!(), + // }) + // } else { + // Option::None + // }; + let executable = Option::None; let response = CompileResponse { executable,