minexew / templeos-loader

User-space loader for TempleOS
4 stars 6 forks source link

Update readme, fix CMake to create static binary #1

Closed tos11 closed 4 years ago

minexew commented 4 years ago

I'm wondering, what happens when you leave out the -static flag? Since the program only links libraries that we build ourselves as static, and musl-gcc should setup stuff like crt0, what else can end up dynamically linked?

tos11 commented 4 years ago

It appears (at least on Ubuntu) without adding the -static flag, it will statically link everything, but still create a "dynamic program" which requires the dynamic linker. I'm not sure why, it doesn't make sense to me either. Adding static removes the dependency on /lib/ld-musl-x86_64.so.1

Without static: $ ldd templeos-loader-no-static statically linked $ readelf -a templeos-loader-no-static | grep ".so" [Requesting program interpreter: /lib/ld-musl-x86_64.so.1]

With static: $ ldd templeos-loader-static not a dynamic executable

minexew commented 4 years ago

Ah cool, I hadn't realized this distinction!