Skip to content

Support c/c++ library internal LTO #1565

@NobodyXu

Description

@NobodyXu

In #1564 we disabled LTO if linker-plugin-lto is not passed in to fix compilation on certain environment.

We could reclaim back the performance, by doing a c/c++ library internal LTO, similar to rustc's crate internal LTO.

To find these tools, we might want 'clang -print-resource-dir', or combined with env var lookup LLVM_INSTALL_DIR

We should also allow build script to override lto mode.

Did some research, for clang it seems to support this

llvm-link file1.bc file2.bc file3.bc -o merged.bc
llc merged.bc -filetype=obj -o merged.o
I didn't find anyway to achieve that for gcc.

Ok so the opt command from llvm can actually do the optimization, might worth trying to see if it works.

We could do

llvm-link file1.bc file2.bc file3.bc -o merged.bc
opt -O{level} merged.bc
llc merged.bc -filetype=obj -o merged.o

Originally posted by @NobodyXu in #1463

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions