{"id":18016948,"url":"https://github.com/fitzgen/lld-dupe-import","last_synced_at":"2025-04-04T15:32:59.894Z","repository":{"id":66008072,"uuid":"381530806","full_name":"fitzgen/lld-dupe-import","owner":"fitzgen","description":"Reproducible test case for `wasm-ld` not de-duplicating WASI imports","archived":false,"fork":false,"pushed_at":"2021-06-30T00:28:28.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T11:59:42.559Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-30T00:27:20.000Z","updated_at":"2021-06-30T00:28:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e7214a6-d923-41ed-98e8-9c420515390c","html_url":"https://github.com/fitzgen/lld-dupe-import","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flld-dupe-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flld-dupe-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flld-dupe-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flld-dupe-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/lld-dupe-import/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247202754,"owners_count":20900836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T04:19:45.292Z","updated_at":"2025-04-04T15:32:59.876Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `wasm-ld` does not de-duplicate WASI imports between different languages\n\nThis test case links C into a Rust project. I've also reproduced this by linking\nRust into a C project. I assume other languages linked together with `wasm-ld`\nwould have the same issue?\n\nI can't find any `wasm-ld` CLI flags that seem to control\nthis. Enabling/disabling LTO and GC sections, for example, doesn't make a\ndifference.\n\n## Steps to Reproduce\n\n* Ensure you have Rust toolchain that can target `wasm32-wasi`:\n\n  ```\n  $ rustup target add wasm32-wasi\n  ```\n\n* Ensure you have a C toolchain that can target `wasm32-unknown-wasi`. Multiple\n  ways to do this, easiest is via\n  [wasi-sdk](https://github.com/WebAssembly/wasi-sdk).\n\n* Clone this repo and `cd` into it.\n\n* Build:\n\n  ```\n  $ CC=path/to/wasi-sdk/bin/clang \\\n    SYSROOT=path/to/wasi-sdk/share/wasi-sysroot \\\n    RANLIB=path/to/wasi-sdk/bin/ranlib \\\n    cargo build --target wasm32-wasi\n  ```\n\n* Inspect the built `.wasm` file's imports:\n\n  ```\n  $ wasm-objdump -x -j Import target/wasm32-wasi/debug/lld_dupe_import.wasm\n  ```\n\n## Expected Results\n\n`\"wasi_snapshot_preview1\" \"fd_write\"` is imported once.\n\n## Actual Results\n\n`\"wasi_snapshot_preview1\" \"fd_write\"` is imported twice:\n\n```\nlld_dupe_import.wasm:\tfile format wasm 0x1\n\nSection Details:\n\nImport[8]:\n - func[0] sig=7 \u003c_ZN4wasi13lib_generated22wasi_snapshot_preview18fd_write17h133cd9fedd86597bE\u003e \u003c- wasi_snapshot_preview1.fd_write\n - func[1] sig=0 \u003c__wasi_proc_exit\u003e \u003c- wasi_snapshot_preview1.proc_exit\n - func[2] sig=3 \u003c__wasi_environ_sizes_get\u003e \u003c- wasi_snapshot_preview1.environ_sizes_get\n - func[3] sig=3 \u003c__wasi_environ_get\u003e \u003c- wasi_snapshot_preview1.environ_get\n - func[4] sig=8 \u003c__wasi_fd_seek\u003e \u003c- wasi_snapshot_preview1.fd_seek\n - func[5] sig=7 \u003c__wasi_fd_write\u003e \u003c- wasi_snapshot_preview1.fd_write\n - func[6] sig=9 \u003c__wasi_fd_close\u003e \u003c- wasi_snapshot_preview1.fd_close\n - func[7] sig=3 \u003c__wasi_fd_fdstat_get\u003e \u003c- wasi_snapshot_preview1.fd_fdstat_get\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Flld-dupe-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Flld-dupe-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Flld-dupe-import/lists"}