]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/cryptsetup-util: build problematic code only in developer mode
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2023 16:28:06 +0000 (17:28 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 28 Nov 2023 20:23:45 +0000 (20:23 +0000)
This code doesn't link when gcc+lld is used:

$ LDFLAGS=-fuse-ld=lld meson setup build-lld && ninja -C build-lld udevadm
...
ld.lld: error: src/shared/libsystemd-shared-255.a(libsystemd-shared-255.a.p/cryptsetup-util.c.o):
  symbol crypt_token_external_path@@ has undefined version
collect2: error: ld returned 1 exit status

As a work-around, restrict it to developer mode.

Closes https://github.com/systemd/systemd/issues/30218.

docs/ENVIRONMENT.md
src/shared/cryptsetup-util.c

index 534490e0e0e9ceeff6df31f2d8eb9a6ab8fe4ba3..5e15b2ba1d62e750433adac6af9ed1992bec209c 100644 (file)
@@ -472,7 +472,8 @@ disk images with `--image=` or similar:
 * `$SYSTEMD_CRYPTSETUP_TOKEN_PATH` – takes a path to a directory in the file
   system. If specified overrides where libcryptsetup will look for token
   modules (.so). This is useful for debugging token modules: set this
-  environment variable to the build directory and you are set.
+  environment variable to the build directory and you are set. This variable
+  is only supported when systemd is compiled in developer mode.
 
 Various tools that read passwords from the TTY, such as `systemd-cryptenroll`
 and `homectl`:
index 19241015fb1eb815cb30275919e4dfc02a29ca81..ab5764dc1057dfa05ff1b54ac31b1d550af9066b 100644 (file)
@@ -72,8 +72,7 @@ int (*sym_crypt_volume_key_keyring)(struct crypt_device *cd, int enable);
 
 /* Do this only on new enough compilers that actually support the "symver" attribute. Given this is a debug
  * feature, let's simply not bother on older compilers */
-#if defined __has_attribute
-#if __has_attribute(symver)
+#if BUILD_MODE_DEVELOPER && defined(__has_attribute) && __has_attribute(symver)
 const char *my_crypt_token_external_path(void); /* prototype for our own implementation */
 
 /* We use the "symver" attribute to mark this implementation as the default implementation, and drop the
@@ -97,7 +96,6 @@ _public_ const char *my_crypt_token_external_path(void) {
         return NULL;
 }
 #endif
-#endif
 
 static void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {