{"id":24452561,"url":"https://github.com/dtcxzyw/conservative-clang","last_synced_at":"2025-04-13T00:55:31.893Z","repository":{"id":273363838,"uuid":"838087544","full_name":"dtcxzyw/conservative-clang","owner":"dtcxzyw","description":"An early LLVM pass which removes most of UB-implying information","archived":false,"fork":false,"pushed_at":"2025-04-01T07:38:03.000Z","size":29,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T00:55:22.318Z","etag":null,"topics":["clang","compiler","llvm","llvm-pass","optimzation","undefined-behavior"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtcxzyw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-04T22:39:47.000Z","updated_at":"2025-04-01T07:38:06.000Z","dependencies_parsed_at":"2025-01-20T13:58:32.083Z","dependency_job_id":null,"html_url":"https://github.com/dtcxzyw/conservative-clang","commit_stats":null,"previous_names":["dtcxzyw/conservative-clang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtcxzyw%2Fconservative-clang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtcxzyw%2Fconservative-clang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtcxzyw%2Fconservative-clang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtcxzyw%2Fconservative-clang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtcxzyw","download_url":"https://codeload.github.com/dtcxzyw/conservative-clang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650438,"owners_count":21139672,"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":["clang","compiler","llvm","llvm-pass","optimzation","undefined-behavior"],"created_at":"2025-01-21T01:15:53.157Z","updated_at":"2025-04-13T00:55:31.868Z","avatar_url":"https://github.com/dtcxzyw.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conservative-Clang\n\nConservative-Clang: An early LLVM pass which removes most of UB-implying information.\n\nIf you are fighting with C/C++ undefined behavior (or clang miscompilation bugs), please try this tool :)\n\nBefore using the pass, please try with the following compilation flags in [clang-flags.txt](./clang-flags.txt):\n\n```\n-fwrapv -fno-check-new -fno-delete-null-pointer-checks -fno-strict-aliasing -fno-strict-enums -fno-strict-float-cast-overflow -fno-strict-return -fno-strict-vtable-pointers -fno-struct-path-tbaa -fno-pointer-tbaa -fno-assume-nothrow-exception-dtor -fno-assume-sane-operator-new -fno-assume-unique-vtables -fno-assumptions -fno-finite-loops -fno-common -mno-global-merge -fno-merge-all-constants -fno-strict-overflow\n```\n\nIf this \"magical formula\" does not work, please try the LLVM pass.\n\nThis work is inspired by Daniel J. Bernstein's [blog](https://blog.cr.yp.to/20240803-clang.html). I hope this work can unblock your project at the prototype stage.\n\n## Getting Started\n\n### Installation\n\n```bash\nsudo apt install llvm-20-dev # Depends on your clang version\ngit clone https://github.com/dtcxzyw/conservative-clang.git\ncd conservative-clang\nmkdir -p build \u0026\u0026 cd build\ncmake .. -DCMAKE_BUILD_TYPE=Release\ncmake --build . -j\n```\n\n### Usage\n\n```bash\nexport CFLAGS=-fpass-plugin=\u003cpath to conservative-clang\u003e/build/cclang.so\nexport CXXFLAGS=-fpass-plugin=\u003cpath to conservative-clang\u003e/build/cclang.so\n# Configure \u0026 build your project\n```\n\nIf you are using CMake, please pass `-DCMAKE_C_FLAGS=-fpass-plugin=\u003cpath to conservative-clang\u003e/build/cclang.so -DCMAKE_CXX_FLAGS=-fpass-plugin=\u003cpath to conservative-clang\u003e/build/cclang.so` to CMake.\n\n## Performance\n\nI did some performance evaluation on llvm test-suite. This pass can result in ~10% performance degradation on average.\n\n## License\n\nThis project is licensed under the Apache License 2.0. Please see the [LICENSE](./LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtcxzyw%2Fconservative-clang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtcxzyw%2Fconservative-clang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtcxzyw%2Fconservative-clang/lists"}