-
-
Save atsushieno/9116656290e1a028c0074cba1943a7ce to your computer and use it in GitHub Desktop.
LTO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: run | |
x: | |
clang++ -g -O0 -shared -fPIC x.cpp -o libx.so | |
y: x | |
clang++ -g -O0 -shared -fPIC y.cpp -o liby.so -L . -l x | |
z: y | |
clang++ -g -O0 z.cpp -o z -L . -lx -ly -lc++ -flto | |
run: z | |
LD_LIBRARY_PATH=. ./z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x() { return 5; } | |
int a() { return 0; } | |
extern "C" __attribute__ ((visibility ("default"))) int b() { return 7; } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x(); | |
int y() { return x() + 3; } | |
int a() { return 4; } | |
extern "C" __attribute__ ((visibility ("default"))) int b() { return 8; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int x(); | |
int y(); | |
int a(); | |
//extern "C" int b(); | |
extern "C" __attribute__ ((visibility ("default"))) int b() { return 20; } | |
int main() { std::cout << x() + y() + a() + b() << std::endl; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment