Skip to content

build.zig: Warn if "config.h" cannot be located - #12133

Merged
andrewrk merged 1 commit into
ziglang:masterfrom
topolarity:config-h-warning
Jul 29, 2022
Merged

build.zig: Warn if "config.h" cannot be located#12133
andrewrk merged 1 commit into
ziglang:masterfrom
topolarity:config-h-warning

Conversation

@topolarity

@topolaritytopolarity commented Jul 16, 2022

Copy link
Copy Markdown
Contributor

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

Vexu commented Jul 16, 2022

Copy link
Copy Markdown
Member

Previous discussion: #11501 (review)

@topolarity

topolarity commented Jul 16, 2022

Copy link
Copy Markdown
ContributorAuthor

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.

@topolaritytopolarity changed the title build.zig: Try harder to find "config.h"build.zig: Install "config.h" to prefix pathJul 19, 2022
@topolarity

Copy link
Copy Markdown
ContributorAuthor

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.

@andrewrkandrewrk left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

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.

@topolaritytopolarity changed the title build.zig: Install "config.h" to prefix pathbuild.zig: Warn if "config.h" cannot be locatedJul 19, 2022
@topolarity
topolarity requested a review from andrewrkJuly 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:masterJul 29, 2022
Sign up for freeto 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

@topolarity@Vexu@andrewrk