diff --git a/packages/rust/cargo.tg.ts b/packages/rust/cargo.tg.ts index 784252aa..f7721092 100644 --- a/packages/rust/cargo.tg.ts +++ b/packages/rust/cargo.tg.ts @@ -419,7 +419,7 @@ export const testUnproxiedWorkspace = tg.target(async () => { const helloWorkspace = build({ source: tests.get("hello-workspace").then(tg.Directory.expect), env: { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", }, proxy: false, }); @@ -433,7 +433,7 @@ export const testUnproxiedWorkspace = tg.target(async () => { const helloOpenssl = build({ source: tests.get("hello-openssl").then(tg.Directory.expect), env: std.env.arg(openssl(), pkgConfig(), { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", }), proxy: false, }); diff --git a/packages/rust/proxy/Cargo.lock b/packages/rust/proxy/Cargo.lock index 38758efe..eabccab0 100644 --- a/packages/rust/proxy/Cargo.lock +++ b/packages/rust/proxy/Cargo.lock @@ -544,9 +544,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -1374,7 +1374,7 @@ dependencies = [ [[package]] name = "tangram_client" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "blake3", "bytes", @@ -1417,7 +1417,7 @@ dependencies = [ [[package]] name = "tangram_either" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "serde", ] @@ -1425,7 +1425,7 @@ dependencies = [ [[package]] name = "tangram_futures" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "dashmap", "futures", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "tangram_http" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "bytes", "erased-serde", @@ -1448,6 +1448,7 @@ dependencies = [ "http-body-util", "hyper", "hyper-util", + "pin-project", "serde", "serde_json", "serde_urlencoded", @@ -1473,7 +1474,7 @@ dependencies = [ [[package]] name = "tangram_uri" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "derive_more", "once_cell", @@ -1484,7 +1485,7 @@ dependencies = [ [[package]] name = "tangram_version" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "derive_more", "winnow", @@ -1585,9 +1586,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", diff --git a/packages/rust/proxy/Cargo.toml b/packages/rust/proxy/Cargo.toml index a275c41f..f4b5cace 100644 --- a/packages/rust/proxy/Cargo.toml +++ b/packages/rust/proxy/Cargo.toml @@ -20,7 +20,7 @@ futures = "0.3" itertools = "0.13" serde = { version = "1", features = ["derive"] } serde_json = "1" -tangram_client = { default-features = false, git = "https://github.com/tangramdotdev/tangram", rev = "30c06cecbd9bff93542e72e94ea109e9ea6ac414" } +tangram_client = { default-features = false, git = "https://github.com/tangramdotdev/tangram", rev = "acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" } tokio = { version = "1", default-features = false, features = [ "rt", "fs", diff --git a/packages/std/Cargo.lock b/packages/std/Cargo.lock index 5a6d40c9..12f68119 100644 --- a/packages/std/Cargo.lock +++ b/packages/std/Cargo.lock @@ -571,9 +571,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -1459,7 +1459,7 @@ dependencies = [ [[package]] name = "tangram_client" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "blake3", "bytes", @@ -1502,7 +1502,7 @@ dependencies = [ [[package]] name = "tangram_either" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "serde", ] @@ -1510,7 +1510,7 @@ dependencies = [ [[package]] name = "tangram_futures" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "dashmap", "futures", @@ -1523,7 +1523,7 @@ dependencies = [ [[package]] name = "tangram_http" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "bytes", "erased-serde", @@ -1533,6 +1533,7 @@ dependencies = [ "http-body-util", "hyper", "hyper-util", + "pin-project", "serde", "serde_json", "serde_urlencoded", @@ -1587,7 +1588,7 @@ dependencies = [ [[package]] name = "tangram_uri" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "derive_more", "once_cell", @@ -1598,7 +1599,7 @@ dependencies = [ [[package]] name = "tangram_version" version = "0.0.0" -source = "git+https://github.com/tangramdotdev/tangram?rev=30c06cecbd9bff93542e72e94ea109e9ea6ac414#30c06cecbd9bff93542e72e94ea109e9ea6ac414" +source = "git+https://github.com/tangramdotdev/tangram?rev=acb0a4794a8758988ca6b1429bb3d9897eb9a3b4#acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" dependencies = [ "derive_more", "winnow", @@ -1726,9 +1727,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 569030f3..f5e366f4 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -33,7 +33,7 @@ itertools = "0.13" libc = "0.2" serde = { version = "1", features = ["derive"] } serde_json = "1" -tangram_client = { default-features = false, git = "https://github.com/tangramdotdev/tangram", rev = "30c06cecbd9bff93542e72e94ea109e9ea6ac414" } +tangram_client = { default-features = false, git = "https://github.com/tangramdotdev/tangram", rev = "acb0a4794a8758988ca6b1429bb3d9897eb9a3b4" } tempfile = "3" tokio = { version = "1", default-features = false, features = [ "rt", diff --git a/packages/std/assert.tg.ts b/packages/std/assert.tg.ts index d4982085..58a5e2ad 100644 --- a/packages/std/assert.tg.ts +++ b/packages/std/assert.tg.ts @@ -459,7 +459,7 @@ export const dlopen = async (arg: DlopenArg) => { directory, ...arg.runtimeDepDirs, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", }, arg.env, ), diff --git a/packages/std/packages/ld_proxy/src/main.rs b/packages/std/packages/ld_proxy/src/main.rs index ecbe6610..5a193e5a 100644 --- a/packages/std/packages/ld_proxy/src/main.rs +++ b/packages/std/packages/ld_proxy/src/main.rs @@ -30,7 +30,7 @@ fn main() { fn main_inner() -> tg::Result<()> { // Read the options from the environment and arguments. let options = read_options()?; - tangram_std::tracing::setup("TANGRAM_LD_PROXY_TRACING"); + tangram_std::tracing::setup("TANGRAM_LINKER_TRACING"); tracing::debug!(?options); // Run the command. @@ -73,7 +73,7 @@ struct Options { /// Paths which may contain additional dynamic libraries passed on the command line, not via a library path. additional_library_candidate_paths: Vec, - /// Library path optimization strategy. Select `resolve`, `filter`, `combine`, or `none`. Defaults to `combine`. + /// Library path optimization level. Select `none`, `filter`, `resolve`, or `combine`. Defaults to `resolve`. library_path_optimization: LibraryPathOptimizationLevel, /// The path to the command that will be invoked. @@ -713,12 +713,12 @@ enum InterpreterRequirement { enum LibraryPathOptimizationLevel { /// Do not optimize library paths. None = 0, - /// Resolve any artifacts with subpaths to their innermost directory. The `Filter` and `Combine` strategies will also perform this optimization first. - Resolve = 1, - /// Filter library paths for needed libraries. - Filter = 2, - /// Combine library paths into a single directory. + /// Only retain paths containing needed libraries. + Filter = 1, + /// Resolve any artifacts with subpaths to their innermost directory. #[default] + Resolve = 2, + /// Combine library paths into a single directory. Combine = 3, } @@ -728,8 +728,8 @@ impl std::str::FromStr for LibraryPathOptimizationLevel { fn from_str(s: &str) -> Result { match s.to_ascii_lowercase().as_str() { "none" | "0" => Ok(Self::None), - "resolve" | "1" => Ok(Self::Resolve), - "filter" | "2" => Ok(Self::Filter), + "filter" | "1" => Ok(Self::Filter), + "resolve" | "2" => Ok(Self::Resolve), "combine" | "3" => Ok(Self::Combine), _ => { // If the string is a digit greater than 3, fall back to 3. @@ -819,21 +819,21 @@ async fn optimize_library_paths( return Ok(library_paths); } - // Resolve any artifacts with subpaths to their innermost directory. - let resolved_dirs: HashSet, H> = - resolve_directories(tg, &library_paths).await?; - tracing::trace!(?resolved_dirs, "post-resolve"); - if matches!(strategy, LibraryPathOptimizationLevel::Resolve) { - return finalize_library_paths(tg, resolved_dirs, needed_libraries).await; - } - // Find all the transitive needed libraries of the output file we can locate in the library path. - find_transitive_needed_libraries(tg, file, &resolved_dirs, needed_libraries, max_depth, 0) + find_transitive_needed_libraries(tg, file, &library_paths, needed_libraries, max_depth, 0) .await?; tracing::trace!(?needed_libraries, "post-find"); + let filtered_library_paths = needed_libraries.values().flatten().cloned().collect(); if matches!(strategy, LibraryPathOptimizationLevel::Filter) { - let resolved_dirs = needed_libraries.values().flatten().cloned().collect(); - return finalize_library_paths(tg, resolved_dirs, needed_libraries).await; + return finalize_library_paths(tg, filtered_library_paths, needed_libraries).await; + } + + // Resolve any artifacts with subpaths to their innermost directory. + let resolved_library_paths: HashSet, H> = + resolve_directories(tg, &filtered_library_paths).await?; + tracing::trace!(?resolved_library_paths, "post-resolve"); + if matches!(strategy, LibraryPathOptimizationLevel::Resolve) { + return finalize_library_paths(tg, resolved_library_paths, needed_libraries).await; } if !matches!(strategy, LibraryPathOptimizationLevel::Combine) { @@ -842,6 +842,7 @@ async fn optimize_library_paths( )); } + // Create a directory combining all located library files. let mut entries = BTreeMap::new(); for (name, dir_id_referent) in needed_libraries.iter() { if let Some(dir_id_referent) = dir_id_referent { @@ -858,26 +859,26 @@ async fn optimize_library_paths( dir_id_referent_from_directory(tg, &tg::Directory::with_entries(entries), None).await?; Some(referent) }; - let resolved_dirs = dir_id.into_iter().collect(); + let combined_library_path = dir_id.into_iter().collect(); - finalize_library_paths(tg, resolved_dirs, needed_libraries).await + finalize_library_paths(tg, combined_library_path, needed_libraries).await } /// Produce the set of library paths to be written to the wrapper post-optimization. async fn finalize_library_paths( tg: &impl tg::Handle, - resolved_dirs: HashSet, H>, + library_paths: HashSet, H>, needed_libraries: &HashMap>, H>, ) -> tg::Result, H>> { - futures::future::try_join_all(resolved_dirs.iter().map(|referent| async { + futures::future::try_join_all(library_paths.iter().map(|referent| async { let directory = directory_from_dir_id_referent(tg, referent).await?; let arg = tg::artifact::checkout::Arg::default(); tg::Artifact::from(directory).check_out(tg, arg).await?; Ok::<_, tg::Error>(()) })) .await?; - report_missing_libraries(tg, needed_libraries, &resolved_dirs).await?; - Ok(resolved_dirs) + report_missing_libraries(tg, needed_libraries, &library_paths).await?; + Ok(library_paths) } /// Given a list of needed library names and a set of selected paths, report which libraries are not accounted for. diff --git a/packages/std/sdk.tg.ts b/packages/std/sdk.tg.ts index 806e57ee..f6072bf3 100644 --- a/packages/std/sdk.tg.ts +++ b/packages/std/sdk.tg.ts @@ -722,7 +722,7 @@ export namespace sdk { ${cmd} -v -x${langStr} ${testProgram} -o $OUTPUT`, { env: std.env.arg(arg.sdkEnv, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", }), host: std.triple.archAndOs(expectedHost), }, diff --git a/packages/std/sdk/proxy.tg.ts b/packages/std/sdk/proxy.tg.ts index a2318929..85f57e05 100644 --- a/packages/std/sdk/proxy.tg.ts +++ b/packages/std/sdk/proxy.tg.ts @@ -406,7 +406,7 @@ int main() { cc -v -xc ${helloSource} -o $OUTPUT`, { env: await std.env.arg(bootstrapSDK, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", TANGRAM_LINKER_LIBRARY_PATH_OPT_LEVEL: "combine", TANGRAM_WRAPPER_TRACING: "tangram=trace", }), @@ -557,7 +557,7 @@ const char* getGreetingB(); tg`cc -v -L${greetA}/lib -L${constantsA}/lib -lconstantsa -I${greetA}/include -lgreeta -I${constantsB}/include -L${constantsB}/lib -lconstantsb -I${greetB}/include -L${greetB}/lib -Wl,-rpath,${greetB}/lib ${greetB}/lib/libgreetb.${dylibExt} -lgreetb -xc ${mainSource} -o $OUTPUT`, { env: await std.env.arg(bootstrapSDK, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", TANGRAM_LINKER_LIBRARY_PATH_OPT_LEVEL: "combine", }), }, @@ -615,7 +615,7 @@ export const testSamePrefix = tg.target(async () => { `, { env: await std.env.arg(bootstrapSDK, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", TANGRAM_LINKER_LIBRARY_PATH_OPT_LEVEL: "combine", }), }, @@ -670,7 +670,7 @@ export const testSamePrefixDirect = tg.target(async () => { `, { env: await std.env.arg(bootstrapSDK, { - TANGRAM_LD_PROXY_TRACING: "tangram=trace", + TANGRAM_LINKER_TRACING: "tangram=trace", TANGRAM_LINKER_LIBRARY_PATH_OPT_LEVEL: "combine", }), },