-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement standard library path search #463
Comments
This should help us provide a static zig.exe for windows that works with no hassle. I'm thinking just a .zip file that you extract to a directory, and viola. Zig compiler. |
Ooh, nice! Could you extend that to multiple directories? Either via multiple --zig-std-dir argument pairs or via some separator and multiple directories in the argument. One reason to do it with multiple --zig-std-dir argument pairs would be that then you do not need to try to match different OS's separators to keep the paths separate:
If this is to point the compiler at the library, would it make more sense to use --zig-std-lib? Will the compiler read environment variables? I.e. set ZIG_STD_DIR to get the same behavior as the original proposal? |
@kyle-github What's the purpose of multiple directories? |
If I want to use a standard install on the system (read-only directory) and still install code in my own home directory, then I will want to search multiple paths. With many languages, some extensions/libraries are installed at the system level and others are local. The same things happens when searching for binary libraries. |
The proposed solution supports up to 2 paths, the relative path and the shared global path, what would be the reason for adding more? For the sake of clarity I'm going to include an example of how this might work. Say
The idea is that each instance of
So as long as the standard library path is not overriden with With this new methodology of each compiler having it's own instance of the standard library, there doesn't seem to be much use for even having a single shared global standard library let alone have multiple versions of the standard library living on the system. And for the purposes of temporarily using a different version of the standard library, the single |
Hmm. OK, I see your reasoning. Thanks. |
If the command line
--zig-std-dir
is given, use that path and assert an error if the path doesn't exist. When the option is not given, check if the standard library lives in a path relative to where the zig executable is installed. If it does not exist there, then look for the standard library using a hardcoded value that was provided when zig was compiled. This could be some default path or could have been customized for a specific zig build.The text was updated successfully, but these errors were encountered: