Passing environment variables to C compiler

Pretty straightforward here, currently when I want to add a system dependency, I have to manually specify linker and header with the -L and -I flags. Normally gcc or clang would get these from environment variables such as LD_LIBRARY_PATH, but these variables don't seem to be passed along. Is there a way to accomplish this, and if not, is there a reason why this doesn't work?

-Xcc allows you to pass flags to the C compiler.

I'm aware of that, I'm currently compiling with the -Xcc flags. But it's a big inconvenience when I have many paths for includes and libraries. It would be great if the compiler picked these up from the environment variables. Generic clang/llvm does this so I'm not sure why it doesn't work with Swift build. Also an inconvenience when using sourcekit-lsp since it doesn't know to apply these compiler flags.

Terms of Service

Privacy Policy

Cookie Policy