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

Use the Lambda executable as the bootstrap when glibc is not required #191

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 2 additions & 11 deletions packaging/packager
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,11 @@ exec \$LAMBDA_TASK_ROOT/lib/$PKG_LD --library-path \$LAMBDA_TASK_ROOT/lib \$LAMB
EOF
)

bootstrap_script_no_libc=$(cat <<EOF
#!/bin/bash
set -euo pipefail
export AWS_EXECUTION_ENV=lambda-cpp
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$LAMBDA_TASK_ROOT/lib
exec \$LAMBDA_TASK_ROOT/bin/$PKG_BIN_FILENAME \${_HANDLER}
EOF
)

cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
if [[ $INCLUDE_LIBC == true ]]; then
cp "$PKG_BIN_PATH" "$PKG_DIR/bin"
echo -e "$bootstrap_script" > "$PKG_DIR/bootstrap"
else
echo -e "$bootstrap_script_no_libc" > "$PKG_DIR/bootstrap"
cp "$PKG_BIN_PATH" "$PKG_DIR/bootstrap"
fi
chmod +x "$PKG_DIR/bootstrap"
# some shenanigans to create the right layout in the zip file without extraneous directories
Expand Down
9 changes: 3 additions & 6 deletions tests/resources/lambda_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ int main(int argc, char* argv[])
handlers.emplace("binary_response", binary_response);
handlers.emplace("crash_backtrace", crash_backtrace);

if (argc < 2) {
aws::logging::log_error("lambda_fun", "Missing handler argument. Exiting.");
return -1;
}

auto it = handlers.find(argv[1]);
// Read the handler from the environment variable
const char* handler_name = std::getenv("_HANDLER");
auto it = handlers.find(handler_name == nullptr ? "" : handler_name);
if (it == handlers.end()) {
aws::logging::log_error("lambda_fun", "Handler %s not found. Exiting.", argv[1]);
return -2;
Expand Down