Skip to content

Conversation

@topolarity
Copy link
Contributor

@topolarity topolarity commented Jul 16, 2022

Adds a warning if config.h could not be located:

$ ./stage2/bin/zig build -Dlog -Denable-llvm --zig-lib-dir lib --prefix $(pwd)/stage3 --search-prefix ~/local/llvm13-release
warning: config.h could not be located automatically. Consider providing it explicitly via "-Dconfig_h"

The search for "config.h" now also stops early if it sees a .git folder, so that we don't go beyond the repo root.

@Vexu
Copy link
Member

Vexu commented Jul 16, 2022

Previous discussion: #11501 (review)

@topolarity
Copy link
Contributor Author

topolarity commented Jul 16, 2022

Thanks for the context @Vexu - I'll have to rework this one, clearly.

I wonder if copying the config.h into the installation during the build would be acceptable? This way Zig would inherit its build settings from the Zig building it.

@topolarity topolarity changed the title build.zig: Try harder to find "config.h" build.zig: Install "config.h" to prefix path Jul 19, 2022
@topolarity
Copy link
Contributor Author

Added a command to copy "config.h" to the output directory during installation. The intention is that a build of Zig should bootstrap itself with the build configuration used to build it, by default.

We may not want "config.h" in the install dir, though. In that case, I'll have to go back to the drawing board.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really think config.h belongs in the installation of Zig. Although I admit it's mostly personal taste, if you produce an installation of Zig using Zig without going through stage1, then no config.h is produced. It seems like, therefore, a canonical installation of Zig does not include config.h.

Is there something wrong with the recommended way to handle stage1, stage2, and stage3 installations side-by-side by running commands directly from the cmake build directory, or by passing -Dconfig_h with the zig build commands?

@topolarity
Copy link
Contributor Author

I share your preference actually 👌

Is there something wrong with the recommended way to handle stage1, stage2, and stage3 installations side-by-side by running commands directly from the cmake build directory, or by passing -Dconfig_h with the zig build commands?

I think this behavior is perfectly fine with the warning added. Let me scale back the change to just that.

@topolarity topolarity changed the title build.zig: Install "config.h" to prefix path build.zig: Warn if "config.h" cannot be located Jul 19, 2022
@topolarity topolarity requested a review from andrewrk July 19, 2022 23:57
We now warn the user if config.h could not be located.

This also updates the search to stop early upon encountering a
`.git` directory, so that we avoid recursing outside of the zig
source if possible.
@andrewrk andrewrk merged commit 4fc2acd into ziglang:master Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants