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

Fix and CI static builds #3765

Open
wants to merge 13 commits into
base: master
from

Conversation

@Ericson2314
Copy link
Member

Ericson2314 commented Jun 29, 2020

We like static builds because we can use to make demos more self-contained and less spooky on systems without a regular installation of Nix.

There number of things that didn't work out of the box also makes us think CI would be a good idea. Static linking shouldn't be this invasive for most programs, but a few things have accumulated. Hopefully we can eventually fix them more elegantly by using a non-bespoke build system (that e.g. could use pkg-config private deps to figure out the right link order).

musl doesn't like this identifier
this is needed for static linking to work properly
this seems to break in Musl/Static with:

terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call
@Ericson2314 Ericson2314 changed the title Fix and ci static builds Fix and CI static builds Jun 29, 2020
@@ -32,7 +32,7 @@ define build-program
$$(eval $$(call create-dir, $$(_d)))

$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) -lz

This comment has been minimized.

Copy link
@matthewbauer

matthewbauer Jun 29, 2020

Member

this probably shouldn't be in upstream

This comment has been minimized.

Copy link
@matthewbauer

matthewbauer Jun 29, 2020

Member

maybe make it conditional on static? by setting GLOBAL_LDFLAGS_AFTER

This comment has been minimized.

Copy link
@Ericson2314

Ericson2314 Jun 29, 2020

Author Member

Well I think it's harmless in non-static ones? All this blah blah_after stuff is still hacky.

This comment has been minimized.

Copy link
@matthewbauer

matthewbauer Jun 29, 2020

Member

Yeah i guess. Maybe just needs a big fixme or something. Libz is in everything so maybe no one will mind.

@@ -511,7 +510,8 @@ std::string getUserName()
}


static Lazy<Path> getHome2([]() {
static Path getHome2()

This comment has been minimized.

Copy link
@matthewbauer

matthewbauer Jun 29, 2020

Member

This is also not equivalent, but i had no idea how to fix lazy for static musl

@Ericson2314 Ericson2314 changed the title Fix and CI static builds Semi-WIP: Fix and CI static builds Jun 30, 2020
@Ericson2314
Copy link
Member Author

Ericson2314 commented Jun 30, 2020

I guess I'll call it semi-wip, hah. It works, but it would be nice to accomplish some things differently.

@domenkozar
Copy link
Member

domenkozar commented Jun 30, 2020

Also needs -A build-static in .github/nix/test.yml

@matthewbauer
Copy link
Member

matthewbauer commented Jul 29, 2020

#3507 has a good explanation of why the getHome* changes are needed.

@Ericson2314 Ericson2314 changed the title Semi-WIP: Fix and CI static builds Fix and CI static builds Jul 30, 2020
@domenkozar domenkozar requested a review from edolstra Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.