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

cmake build system: figure out how to make the zig0 build always execute #2585

Closed
andrewrk opened this issue May 29, 2019 · 0 comments · Fixed by #2892
Closed

cmake build system: figure out how to make the zig0 build always execute #2585

andrewrk opened this issue May 29, 2019 · 0 comments · Fixed by #2892
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@andrewrk
Copy link
Member

Currently the cmake build system will not rebuild libuserland.a unless a select number of files are modified:

zig/CMakeLists.txt

Lines 6720 to 6732 in f9ada1c

add_custom_command(
OUTPUT "${LIBUSERLAND}"
COMMAND zig0 ARGS build
--override-std-dir std
--override-lib-dir "${CMAKE_SOURCE_DIR}"
libuserland
"-Doutput-dir=${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
DEPENDS
"${CMAKE_SOURCE_DIR}/src-self-hosted/stage1.zig"
"${CMAKE_SOURCE_DIR}/src-self-hosted/translate_c.zig"
"${CMAKE_SOURCE_DIR}/build.zig"
)

I was unable to figure out how to make cmake unconditionally run this zig build command (which does its own caching).

Maybe the #cmake IRC channel could help. I didn't get an easy answer when I asked:

<andrewrk> is there a way to tell add_custom_command to always, unconditionally run the command? the command does its own caching
<andrewrk> can I add something to the DEPENDS that is always considered out of date?
<ngladitz> use a custom target instead?
<andrewrk> I think I tried that and it didn't work for some reason. let me refresh my memory
<andrewrk> ngladitz, because I need to depend on the OUTPUT in a target_link_libraries
<andrewrk> https://github.com/ziglang/zig/blob/f9ada1cfba5140ef01baa138813241c6b93a1ea9/CMakeLists.txt#L6720-L6732
<andrewrk> I'm pretty sure I tried add_custom_target first
<ngladitz> add a target interdependency (add_dependencies()) and declare the output in BYPRODUCTS?
<andrewrk> BYPRODUCTS? are we looking at the same documentation? 
<andrewrk> https://cmake.org/cmake/help/v3.0/command/add_custom_target.html
<andrewrk> actually my cmake min version is 2.8.5
<ngladitz> hm you might start questions with that bit of info .. 2.8.5 is like 8(?) years old
<ngladitz> fwiw BYPRODUCTS was introduces in 3.2 but is only required for Ninja
<ngladitz> *introduced
@andrewrk andrewrk added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. stage1 The process of building from source via WebAssembly and the C backend. labels May 29, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone May 29, 2019
mikdusan added a commit to mikdusan/zig that referenced this issue May 29, 2019
- zig0 is always built
- mark custom_command(libuserland) to depend on zig0
- remove redundant depend files from custom_command(libuserland)

closes ziglang#2585
andrewrk added a commit that referenced this issue Jul 15, 2019
This moves the installation of shipped source files from large
CMakeLists.txt lists to zig build recursive directory installation.

On my computer a cmake `make install` takes 2.4 seconds even when it has
to do nothing, and prints a lot of unnecessary lines to stdout that say
"up-to-date: [some file it is installing]".

After this commit, the default output of `make` is down to 1
second, and it does not print any junk to stdout. Further, a `make
install` is no longer required and `make` is sufficient.

This closes #2874.

It also closes #2585. `make` now always invokes `zig build` for
installing files and libuserland.a, and zig's own caching system makes
that go fast.
@andrewrk andrewrk modified the milestones: 0.6.0, 0.5.0 Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
1 participant