stripDeployed walks the per-platform installed tree and runs strip on every ELF file found. Static archives (.a) are intentionally skipped — stripping them removes symbols downstream linking against this deploy still needs.
()
| 152 | // ELF file found. Static archives (.a) are intentionally skipped — stripping |
| 153 | // them removes symbols downstream linking against this deploy still needs. |
| 154 | func (p Project) stripDeployed() error { |
| 155 | // Check if strip executable file has been configured. |
| 156 | toolchain := p.ctx.Platform().GetToolchain() |
| 157 | stripBin := toolchain.GetSTRIP() |
| 158 | if stripBin == "" { |
| 159 | return fmt.Errorf("strip executable file path is not configured in platform: %s.toml", p.ctx.Platform().GetName()) |
| 160 | } |
| 161 | |
| 162 | // Resolve target tree: installed/<platform>/<project>/<buildType>/. |
| 163 | // Dev/host trees are not stripped — those binaries run on the build host |
| 164 | // and people often want their symbols for debugging build issues. |
| 165 | installedDir := p.ctx.InstalledDir() |
| 166 | if !fileio.PathExists(installedDir) { |
| 167 | return nil |
| 168 | } |
| 169 | |
| 170 | color.Printf(color.Title, "\n[strip deployed binaries: %s]\n", installedDir) |
| 171 | err := filepath.WalkDir(installedDir, func(path string, d fs.DirEntry, walkErr error) error { |
| 172 | if walkErr != nil { |
| 173 | return walkErr |
| 174 | } |
| 175 | if d.IsDir() { |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // Skip anything that is obviously not an ELF binary we want to strip. |
| 180 | // Static archives are special: stripping breaks them for downstream linking. |
| 181 | if strings.HasSuffix(path, ".a") { |
| 182 | return nil |
| 183 | } |
| 184 | if !fileio.IsELFFile(path) { |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | if _, err := cmd.NewExecutor("", stripBin, path).ExecuteOutput(); err != nil { |
| 189 | return nil |
| 190 | } |
| 191 | color.PrintHint("✔ strip %s", path) |
| 192 | return nil |
| 193 | }) |
| 194 | if err != nil { |
| 195 | return err |
| 196 | } |
| 197 | |
| 198 | return nil |
| 199 | } |
no test coverage detected