Skip to content
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

Closed
marler8997 opened this issue Sep 10, 2017 · 6 comments
Closed

Implement standard library path search #463

marler8997 opened this issue Sep 10, 2017 · 6 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@marler8997
Copy link
Contributor

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.

@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Sep 10, 2017
@andrewrk andrewrk added this to the 0.1.0 milestone Sep 10, 2017
@andrewrk
Copy link
Member

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.

@kyle-github
Copy link

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:

zig --zig-std-dir c:\users\kyle\myZigInstall --zig-std-dir c:\programs\zigInstall

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?

@marler8997
Copy link
Contributor Author

@kyle-github What's the purpose of multiple directories?

@kyle-github
Copy link

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.

@marler8997
Copy link
Contributor Author

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 zig.exe is installed here:

c:\myzigversion0.1build-a819fec91\zig.exe

The idea is that each instance of zig.exe will always have an instance of the standard library living relative to it. The exact path where it lives is up to Andrew/Josh, but let's say it lives here:

c:\myzigversion0.1build-a819fec91\zig\std

So as long as the standard library path is not overriden with --zig-std-dir, then it should always find the standard library in it's relative path.

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 --zig-std-dir command line option serves this purpose.

@kyle-github
Copy link

Hmm. OK, I see your reasoning. Thanks.

andrewrk added a commit that referenced this issue Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

3 participants