Commit Graph

67 Commits

Author SHA1 Message Date
Rusty Russell 50d1043a91 external: build lowdown if not already found.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-08 00:36:51 +03:00
Rusty Russell 2c72229106 configure: add -Wshadow=local flag.
This will warn us if there are local variables which shadow the
same-named variable.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-08-31 12:18:28 +03:00
Christian Decker 74c3325208 mac: Ensure that we compile the configurator with the M1 libs 2022-07-11 14:06:39 -05:00
Christian Decker e3f53e072f make: Add macos M1 support
The M1 Macs support both x86_64 and arm64 architectures, which forced
homebrew to use a different path for its storage (`/opt/homebrew/`
instead of `/usr/local`). If we don't adjust the path we'd mix x86_64
and arm64 libraries which can lead to weird compiler and linker
errors.

This patch just introduces `CPATH` and `LIBRARY_PATH` as suggested by
the homebrew team, and detects the current architecture automatically.

Changelog-Added: macos: Added m1 architecture support for macos
2022-07-11 14:06:39 -05:00
Clay Shoaf 43ace03685 "removed asterisks, in case that's what made build fail" 2022-05-01 14:36:20 +09:30
Clay Shoaf 55b5653726 Slight problem with `./configure help` 2022-05-01 14:36:20 +09:30
Rusty Russell e5abc10ae2 configure: require rustfmt as well, for rust support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-04-13 05:25:00 +09:30
Rusty Russell 836c1b805b doc: update c-lightning to Core Lightning almost everywhere.
Mostly comments and docs: some places are actually paths, which
I have avoided changing.  We may migrate them slowly, particularly
when they're user-visible.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-04-07 06:53:26 +09:30
Christian Decker edf6832f8f rust: Actually check if we have cargo
Seems a temporary edit to check the detection slipped in during the
previous PR. This fixes that :-)
2022-02-28 23:25:37 +00:00
Rusty Russell 05bd62fee4 configure: restore -Og default on non-developer builds.
Reverts change in 1ef77504b1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-02-28 14:42:41 -06:00
Christian Decker 1ef77504b1 misc: Add build targets for the tarball and debian packages
The tarball needs to materialze all submodules, and git needs to be
removed as a build dependency.
2022-02-22 09:43:56 +10:30
Christian Decker 7fdad0a60c rust: Add rust detection to configure and a target to add binaries
We detect whether we have the rust tooling available (mainly `cargo`)
and enable or disable the rust libraries, plugins and examples when it
is enabled. Since the rest of the Makefiles assumes that executables
have an associated header and C source file, we also needed to add a
target that we can add non-C binaries to.
2022-02-11 16:02:25 +01:00
Rusty Russell 2e01d26588 configure: update from -fstack-protector to -fstack-protector-strong.
This would have caught the bug found in the next commit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-09-02 15:06:18 +02:00
Rusty Russell 225fec065a Build race fixes: create ccan/config.h atomically, make tools/test/test_gen.c depend on it
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-08-14 12:43:54 +09:30
Christian Decker 2a44ad113d configure: Pick up the correct pytest executable
We were looking for `python` in the `pytest --version` output
2021-03-11 14:07:47 +10:30
Christian Decker 16801e31e9 configure: Prefer pytest over pytest3
When looking for a pytest executable we should be looking for the ones
that `pip` installs in a virtualenv (`pytest` and `py.test`) before we
look for the ones that `apt` installs system-wide (`pytest3` and
`py.test3`) because these may not be part of the virtualenv that all
other packages are installed in.
2021-01-08 19:28:30 +01:00
Antoine Poinsot b3594690d9 configure: allow to run with UB sanitizer
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-10-21 19:34:39 +02:00
Antoine Poinsot 62b54d0125 build: introduce a fuzzing mode
This adds a new configuration, --enable-fuzzing (which is more than
welcome to be coupled with --enable-address-sanitizer), to pass the
fuzzer sanitizer argument when compiling objects. This allows libfuzzer
to actually be able "to fuzz" by detecting coverage and be smart when
mutating inputs.

As libfuzzer brings its own ~~fees~~ main(), we compile objects with
fsanitize=fuzzer-no-link, and special-case the linkage of the fuzz
targets.

A "lib" is added to abstract out the interface to the fuzzing tool used.
This allow us to use the same targets to fuzz using AFL, hongfuzz or w/e
by adding their entrypoints into libfuzz. (h/t to practicalswift who
introduced this for bitcoin-core, which i mimiced)

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-10-21 19:34:39 +02:00
grubles 94f84d3843 Update configure
OpenBSD's `sha256sum` equivalent is `sha256`. This adds support in `configure` for it.
2020-10-15 10:39:42 +10:30
Antoine Poinsot 3382dafaee configure: allow to run clang with ASAN
Prefer adding LSAN_OPTIONS="suppressions=$PWD/tests/sanitizer_suppressions/lsan" when CC=clang instead.

Changelog-Added: build: clang build now supports --enable-address-sanitizer .
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-09-24 13:57:43 +09:30
Rusty Russell 4e67b4fd03 Makefile: work with shasum -a as well as sha256sum.
At least on my Ubuntu box, they're compatible. If they're not, we need
to disable regeneration altogether.

Fixes: #4075
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-23 14:34:42 +02:00
Rusty Russell a08e83522b configure: clean up tmpfile if we fail.
Reported-by: @whitslack
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-21 13:07:01 +02:00
Rusty Russell d56f8b6c5d configure: refuse to create config.vars without any database.
We alter the script to do the move to config.vars right at the end,
which is probably a good idea anyway.

Fixes: #4054
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-19 12:38:54 +09:30
Rusty Russell 390c6470ad configure: we don't need mako any more.
And guard the mako-specific tests with a check instead.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-31 21:33:26 -05:00
Matt Whitlock abbc712afb allow building without sqlite3
Changelog-Changed: build: SQLite3 is no longer a hard build requirement. C-Lightning can now be built to support only the PostgreSQL back-end.
2020-08-30 12:44:56 +02:00
Matt Whitlock c1aa33a62a configure: hoist defaulting of PG_CONFIG var to top of script
See: https://github.com/ElementsProject/lightning/pull/3995#discussion_r478899639
2020-08-30 10:24:37 +09:30
Matt Whitlock 94472f67c5 configure: Use pg_config to locate the library location too
Also, allow the pg_config binary to be specified through the PG_CONFIG
environment variable, defaulting to 'pg_config' if unset. Explicitly
setting PG_CONFIG to an empty string will forcibly disable PostgreSQL
support, even if a PostgreSQL library is installed.

Changelog-Fixed: build: On systems with multiple installed versions of the PostgreSQL client library, C-Lightning might link against the wrong version or fail to find the library entirely. `./configure` now uses `pg_config` to locate the library.
2020-08-30 10:24:37 +09:30
Christian Decker 0a501b3646 configure: Use pg_config to locate the header location
Changelog-Fixed: build: On some operating systems the postgresql library would not get picked up. `./configure` now uses `pg_config` to locate the headers.
2020-08-28 11:59:57 +09:30
Niklas Claesson de5eaf2238 configurator: Enable running configurator in wrapper
Since the probing binaries compiled by the configurator needs to run on
the host machine we provide a variable CONFIGURATOR_WRAPPER that can be
set to anything that you want to wrap the calls with.

One example is `qemu-aarch64-static`.
2020-02-06 13:37:54 +10:30
Vasil Dimov cd30f76539 build: fix ./configure options' descriptions
The description of

--enable/disable-experimental-features was a bogus "Developer mode, good
for testing" and

--enable/disable-valgrind was "Valgrind binary to use for tests" which
gave the false impression that it should be set to something like
/usr/local/bin/valgrind whereas it is a boolean option.
2019-12-11 00:50:20 +01:00
Rusty Russell f6571460ff configure: fix FreeBSD which has sqlite3 in /usr/local
Fixes: #3080
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-10-27 21:42:54 -05:00
darosior 4083e077a4 configure: test XChaCha20Poly1305 stream state for HAVE_GOOD_LIBSODIUM
author: @rustyrussell
2019-10-17 23:42:15 +02:00
Rusty Russell c617f19a29 Makefile: fix static linking.
And update --enable-static, since it doesn't actually create a static
binary since 65fa1c4f39.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-10-14 14:04:43 -05:00
Christian Decker 9025a3cd39 pytest: Allow switching chaind depending on a config option
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-10-03 04:32:57 +00:00
Christian Decker 62dc8dc110 make: Add configuration detection and linking of libpq
If we have the client library for postgres configure will define HAVE_POSTGRES
the same way it already handled libsqlite3 an we start linking against it.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-22 02:03:43 +00:00
Rusty Russell 8843ab4fb7 configure: test for pwritev
MacOS doesn't have it apparently.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-11 05:58:36 +00:00
Christian Decker e4ab98459c wallet: Add tooling to extract SQL queries and generate driver info
This is the counterpart of the annotations we did in the last few commits. It
extracts queries, passes them through a driver-specific query rewriter and
dumps them into a driver-specific query-list, along with some metadata to
facilitate processing later on. The generated query list is then registered as
a `db_config` and will be loaded by the driver upon instantiation.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-05 23:41:05 +00:00
Rusty Russell 0fdf22988d configure: absorb python3-mako check.
This is a better place for such checks than the Makefile, and we'll likely
have more in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-21 05:07:15 +00:00
Rusty Russell df298ba7e3 configure: suppress "maybe uninitialized" warnings altogether unless -O3.
We were just telling GCC not to treat them as errors: this suppresses them
entirely unless at -O3.  People keep trying to "fix" them, when in fact
they're false positives, as revealed with "./configure COPTFLAGS=-O3".

Fixes: #2856
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-02 15:56:15 +02:00
Rusty Russell 54b66f0049 configure: fix --reconfigure, improve style, set defaults in one place.
I noticed that DEVELOPER was being reset to 0 by ./configure --reconfigure;
that's because we set the defaults first, then --reconfigure would only
override *unset* vars.  We now set up defaults last.

We unify all our "find the default" functions, to neaten them; in
particular find_pytest and our open-coded valgrind testing function.

We can figure out whether valgrind works using /bin/true instead of waiting
until configurator is built.

We're also more careful with ${FOO-default} vs ${FOO:-default}; the former
does not replace if FOO is set to the empty string, which is possible for
some of our settings (COPTFLAGS, CDEBUGFLAGS in particular).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-07 10:37:52 +02:00
Rusty Russell 7092d215fa configure: detect modern gcc, and only suppress necessary errors.
Drive-by fix of CONFIGURATOR_CC setting when CC is overridden on cmdline
(not via env var).

Note that clang defines __GNUC__ (to 4) :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-03 00:07:11 +00:00
Rusty Russell ed08ca6df3 configure: handle --reconfigure better.
`./configure CC=newcc --reconfigure` didn't set CC, because reconfigure
simply replaced all values: only make it replace undefined values.

Also, it didn't change COPTFLAGS or CWARNFLAGS, even if they were previously
the defaults (eg. --reconfigure --enable-developer).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-03 00:07:11 +00:00
Rusty Russell 6b32b72dee configure: use "-Og" for non-developer builds, add COPTFLAGS variable.
Unfortuntely we get spurious uninitialized variable warnings with
anything but -O3 or no optimization, so set default CWARNFLAGS
appropriately.

MCP bench results without optimization:
   store_load_msec:28509-31001(29206.6+/-9.4e+02)
   vsz_kb:580004-580016(580006+/-4.8)
   store_rewrite_sec:11.640000-12.730000(11.908+/-0.41)
   listnodes_sec:1.790000-1.880000(1.83+/-0.032)
   listchannels_sec:21.180000-21.950000(21.476+/-0.27)
   routing_sec:2.210000-11.160000(7.126+/-3.1)
   peer_write_all_sec:36.270000-41.200000(38.168+/-1.9)

MCP bench with -Og: 22% speedup vs no optimization
   store_load_msec:21963-23645(22841+/-6.6e+02)
   vsz_kb:579916
   store_rewrite_sec:10.080000-10.960000(10.456+/-0.3)
   listnodes_sec:1.280000-1.390000(1.338+/-0.047)
   listchannels_sec:14.770000-16.080000(15.518+/-0.46)
   routing_sec:0.990000-6.660000(3.958+/-2.2)
   peer_write_all_sec:29.950000-32.950000(31.138+/-1)

MCP bench with -O2: 31% speedup vs no optimization
   store_load_msec:20713-22088(21505.6+/-4.8e+02)
   vsz_kb:579928
   store_rewrite_sec:9.570000-11.200000(10.192+/-0.54)
   listnodes_sec:0.960000-1.090000(1.028+/-0.045)
   listchannels_sec:10.400000-11.770000(11.012+/-0.48)
   routing_sec:0.300000-3.140000(1.978+/-1.1)
   peer_write_all_sec:28.980000-30.310000(29.572+/-0.44)

MCP bench with -O3 -flto: 36% speedup vs no optimization
   store_load_msec:19616-20191(19862.6+/-1.9e+02)
   vsz_kb:578452
   store_rewrite_sec:8.980000-9.960000(9.55+/-0.32)
   listnodes_sec:0.920000-1.910000(1.18+/-0.38)
   listchannels_sec:8.960000-9.450000(9.206+/-0.16)
   routing_sec:0.730000-1.850000(1.438+/-0.42)
   peer_write_all_sec:28.090000-29.410000(28.772+/-0.42)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-16 15:39:56 -04:00
GreenAddress fb07265663 remove libbase58, use base58 from libwally (#2594)
* remove libbase58, use base58 from libwally

This removes libbase58 and uses libwally instead.

It allocates and then frees some memory, we may want to
add a function in wally that doesn't or override
wally_operations to use tal.

Signed-off-by: Lawrence Nahum lawrence@greenaddress.it
2019-04-30 23:07:31 +02:00
Rusty Russell 4b91439c08 configure: check for sqlite3_expanded_sql (SQLite3 version 3.14, 2016-08-08)
Our Travis, for example, doesn't have 3.14.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 01:56:17 +00:00
Rusty Russell 102a67cbb2 configure: fix detection of builtin libs with -Werror.
We didn't include stdlib, so these tests "failed" due to implicit
declaration of exit().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 01:56:17 +00:00
Christian Decker 5518c7cba8 configure: Check for lower-case IETF acronym in sodium constants
The v1.0.9 release of libsodium added
crypto_aead_chacha20poly1305_ietf_NPUBBYTES which we use; before that it was
...IETF_NPUBBYTES.

Since that release was in April 2016, it seems fair to simply check for
ancient versions and use the internal one if found. The alternative would be
to use the older names (which are still in the header), but given we've never
tested with such old versions, this seems safer.

Reported-by: Zoltán Gálli <@gallizoltan>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-03-04 02:38:53 +00:00
Rusty Russell d98fb0fd5b configure: remove bashism.
== is bash-only; for other shells this gives an error (meaning that you won't
get the sanity check):

	./configure
	Compiling ccan/tools/configurator/configurator...done
	./configure: 148: [: gcc: unexpected operator

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-28 05:17:21 +00:00
Rusty Russell 17c8090a87 configure: relax --enable-address-sanitizer check a little.
If you use use CC='gcc <options>' this blocks ASAN.  Of course, no
check is perfect, but this catches the obvious misuse still.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-22 11:20:51 -08:00
Rusty Russell d413fc7e9b configure: use system libbase58 if available.
Also one less headache for reproducible builds.  But unlike
libsodium, this only seems common in Ubuntu.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-08 01:10:17 +00:00