{"id":24941961,"url":"https://github.com/jonastoth/llvm-bolt-builds","last_synced_at":"2025-07-24T23:35:59.099Z","repository":{"id":38310766,"uuid":"387234935","full_name":"JonasToth/llvm-bolt-builds","owner":"JonasToth","description":"Dump of Scripts that I used to create Bolted LLVM+Clang Binaries (with additional LTO + PGO)","archived":false,"fork":false,"pushed_at":"2022-07-31T12:55:10.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T15:55:31.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/JonasToth.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}},"created_at":"2021-07-18T17:41:48.000Z","updated_at":"2023-03-23T23:39:14.000Z","dependencies_parsed_at":"2022-08-25T21:21:59.359Z","dependency_job_id":null,"html_url":"https://github.com/JonasToth/llvm-bolt-builds","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/JonasToth%2Fllvm-bolt-builds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasToth%2Fllvm-bolt-builds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasToth%2Fllvm-bolt-builds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasToth%2Fllvm-bolt-builds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonasToth","download_url":"https://codeload.github.com/JonasToth/llvm-bolt-builds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154968,"owners_count":21056541,"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":"2025-02-02T18:57:32.555Z","updated_at":"2025-04-10T03:44:12.659Z","avatar_url":"https://github.com/JonasToth.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How does it work\n\nThis set of scripts creates a 60% faster LLVM toolchain that can be customly\ntrained to any project.\n\nThe full_workflow.bash will autodetect, if your machine supports LBR or not and choose the correct script which suits to your hardware.\n\n## LLVM\n\n### How to build\n\nBe sure to have jemalloc installed, it is used to improve llvm-bolt's memory handling.\n\ngit clone https://github.com/ptr1337/llvm-bolt-scripts.git\ncd llvm-bolt-scripts\n./full_workflow.bash\n\nThis sequence will give you (hopefully) a faster LLVM toolchain.\nTechnologies used:\n\n- LLVM Link Time Optimization (LTO)\n- Binary Instrumentation and Profile-Guided-Optimization (PGO)\n- perf-measurement and branch-sampling/profiling and final binary reordering (BOLT)\n\nThe goal of the techniques is to utilize the CPU black magic better and layout\nthe code in a way, that allows faster execution.\n\nMeasure performance gains and evaluate if its worth the hazzle :)\nYou can experiment with technologies, maybe `ThinLTO` is better then `FullLTO`,\n\nFor the last bit of performance, you can run several different workloads and then merge the resulted profiles with 'merge-fdata \\*.fdata \u003e combined.fdata' and then optimize the libary with llvm-bolt again.\nand nothing else! The same goes for `BOLT`.\n\n## GCC\n\nIf you want to bolt gcc, you need to disable when building gcc the language `lto`, you can still use the gcc lto function but gcc itself wont build with lto. Enabling lto will crash llvm-bolt.\n\nAlso you need to add following to your compileflags:\n\n```\nCXXFLAGS+=\"-fno-reorder-blocks-and-partition\"\nLDFLAGS+=\"--emit-relocs\"\n```\n\nThe compileflas should be used for any binary you compile and want to optimize the binary with bolt.\n\n### Bolting other binarys/\\*.so files\n\nIve included a script which makes it possible to bolt any binary or .so file which got compiled with --emit-relocs.\nust change the binary name and the path to your suits and the STAGE number.\n\nAfter you did run stage 1 you need to run a workload with the instrumented binary/.so file.\n\nWhen the workload is running, you will see that in the FDATA path many profiles are created. These will be in the STAGE2 process merged and then on your binary/.so file used and bolt will optimize it.\n\n#### Example:\n\nWe will now take for example llvm:\n\n    - Compile it with relocations (LDFLAGS+=\"--emit-relocs\") enabled\n    - Install your package\n    - Change the to BINARY=libLLVM.so and the BINARYPATH=/usr/lib to your suits to the target you want to optimize and set STAGE=1\n    - Run the script\n    - After you did run it, it will backup your file and will move the instrumented target to the original path\n    - Run a workload with the target, so compile something with clang\n    - You will get several files into the FDATA path, when you run the workload !!! ATTENTION !!! the size of the data can get quite big, so take a watch at the folder\n    - After youre done with the workload change at the script to STAGE=1\n    - Run the script again and the created data from the instrumentiation will be merged and then used for llvm-bolt to optimize the target\n    - After that it will automatically move it tor your systembinary/libary, a backup and the bolted binary can be found at the binarypath.\n    - Thats it, now repeat the worklow for other targets you want top optimize.\n    - Tip: if you for example instrumented libLLVM the profile is also useable for other llvm based files which where active in the recording process\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonastoth%2Fllvm-bolt-builds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonastoth%2Fllvm-bolt-builds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonastoth%2Fllvm-bolt-builds/lists"}