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

Build script C macro expansion error for cross compiled OpenSSL #1030

Open
repnop opened this issue Dec 14, 2018 · 11 comments
Open

Build script C macro expansion error for cross compiled OpenSSL #1030

repnop opened this issue Dec 14, 2018 · 11 comments

Comments

@repnop
Copy link

repnop commented Dec 14, 2018

error: failed to run custom build command for `openssl-sys v0.9.39`
process didn't exit successfully: `/home/vagrant/pi_monitor_screen/target/debug/build/openssl-sys-c1c9d3e12e9dd62b/build-script-main` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=ARM_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=ARM_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR
cargo:rustc-link-search=native=/home/vagrant/openssl_cross/lib/
cargo:include=/home/vagrant/openssl_cross/include/
OPT_LEVEL = Some("0")
TARGET = Some("arm-unknown-linux-gnueabihf")
HOST = Some("x86_64-unknown-linux-gnu")
CC_arm-unknown-linux-gnueabihf = None
CC_arm_unknown_linux_gnueabihf = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_arm-unknown-linux-gnueabihf = None
CFLAGS_arm_unknown_linux_gnueabihf = None
TARGET_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-march=armv6" "-marm" "-I" "/home/vagrant/openssl_cross/include/" "-Wall" "-Wextra" "-E" "/home/vagrant/pi_monitor_screen/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-8104b0174abe002f/out/expando.c"
cargo:warning=/home/vagrant/pi_monitor_screen/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-8104b0174abe002f/out/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
cargo:warning= #define VERSION2(n, v) RUST_VERSION_ ## n ## _ ## v
cargo:warning=                        ^~~~~~~~~~~~~
cargo:warning=/home/vagrant/pi_monitor_screen/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-8104b0174abe002f/out/expando.c:5:23: note: in expansion of macro 'VERSION2'
cargo:warning= #define VERSION(n, v) VERSION2(n, v)
cargo:warning=                       ^~~~~~~~
cargo:warning=/home/vagrant/pi_monitor_screen/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-8104b0174abe002f/out/expando.c:7:1: note: in expansion of macro 'VERSION'
cargo:warning= VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
cargo:warning= ^~~~~~~
exit code: 1

--- stderr
thread 'main' panicked at '
Header expansion error:
Error { kind: ToolExecError, message: "Command \"arm-linux-gnueabihf-gcc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-g\" \"-fno-omit-frame-pointer\" \"-march=armv6\" \"-marm\" \"-I\" \"/home/vagrant/openssl_cross/include/\" \"-Wall\" \"-Wextra\" \"-E\" \"/home/vagrant/pi_monitor_screen/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-8104b0174abe002f/out/expando.c\" with args \"arm-linux-gnueabihf-gcc\" did not execute successfully (status code exit code: 1)." }
@repnop repnop changed the title Build script C macro expansion for cross compiled OpenSSL Build script C macro expansion error for cross compiled OpenSSL Dec 14, 2018
@sfackler
Copy link
Owner

What does the openssl/opensslv.h header file look like?

@repnop
Copy link
Author

repnop commented Dec 14, 2018

/*
 * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef HEADER_OPENSSLV_H
# define HEADER_OPENSSLV_H

# ifdef  __cplusplus
extern "C" {
# endif

/*
 * SECTION 1: VERSION DATA.  These will change for each release
 */

/*
 * Base version macros
 *
 * These macros express version number MAJOR.MINOR.PATCH exactly
 */
# define OPENSSL_VERSION_MAJOR  3
# define OPENSSL_VERSION_MINOR  0
# define OPENSSL_VERSION_PATCH  0

/*
 * Additional version information, defined only when used.
 *
 * These are also part of the new version scheme, but aren't part
 * of the version number itself.
 */

/* Could be: #define OPENSSL_VERSION_PRE_RELEASE "-alpha.1" */
# define OPENSSL_VERSION_PRE_RELEASE "-dev"
/* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+fips" */
/* Could be: #define OPENSSL_VERSION_BUILD_METADATA "+vendor.1" */
# undef OPENSSL_VERSION_BUILD_METADATA

/*
 * Note: OPENSSL_VERSION_BUILD_METADATA will never be defined by
 * the OpenSSL Project, it's entirely reserved for others vendors
 */

/*
 * Absolute string versions of OPENSSL_VERSION_PRE_RELEASE and
 * OPENSSL_VERSION_BUILD_METADATA.  As opposed to those, which
 * may be undefined, these are guaranteed to have strings as
 * values.
 */

# ifdef OPENSSL_VERSION_PRE_RELEASE
#  define OPENSSL_VERSION_PRE_RELEASE_STR OPENSSL_VERSION_PRE_RELEASE
# else
#  define OPENSSL_VERSION_PRE_RELEASE_STR ""
# endif
# ifdef OPENSSL_VERSION_BUILD_METADATA
#  define OPENSSL_VERSION_BUILD_METADATA_STR OPENSSL_VERSION_BUILD_METADATA
# else
#  define OPENSSL_VERSION_BUILD_METADATA_STR ""
# endif

/*
 * Shared library version
 *
 * This is strictly to express ABI version, which may or may not
 * be related to the API version expressed with the macros above.
 * This is defined in free form.
 */
# define OPENSSL_SHLIB_VERSION 3

/*
 * SECTION 2: USEFUL MACROS AND FUNCTIONS
 */

/* For checking general API compatibility when preprocessing */
# define OPENSSL_VERSION_PREREQ(maj,min)                                \
    ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= (maj << 16) + min)

/* Helper macros for CPP string composition */
#   define OPENSSL_MSTR_HELPER(x) #x
#   define OPENSSL_MSTR(x) OPENSSL_MSTR_HELPER(x)

/*
 * These return the values of OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR,
 * OPENSSL_VERSION_PATCH, OPENSSL_VERSION_PRE_RELEASE and
 * OPENSSL_VERSION_BUILD_METADATA, respectively.
 */
unsigned int OPENSSL_version_major(void);
unsigned int OPENSSL_version_minor(void);
unsigned int OPENSSL_version_patch(void);
const char *OPENSSL_version_pre_release(void);
const char *OPENSSL_version_build_metadata(void);

/*
 * Macros to get the version in easily digested string form, both the short
 * "MAJOR.MINOR.PATCH" variant (where MAJOR, MINOR and PATCH are replaced
 * with the values from the corresponding OPENSSL_VERSION_ macros) and the
 * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and
 * OPENSSL_VERSION_BUILD_METADATA_STR appended.
 */
# define OPENSSL_VERSION_STR                    \
    OPENSSL_MSTR(OPENSSL_VERSION_MAJOR) "."     \
    OPENSSL_MSTR(OPENSSL_VERSION_MINOR) "."     \
    OPENSSL_MSTR(OPENSSL_VERSION_PATCH)
# define OPENSSL_FULL_VERSION_STR               \
    OPENSSL_VERSION_STR                         \
    OPENSSL_VERSION_PRE_RELEASE_STR             \
    OPENSSL_VERSION_BUILD_METADATA_STR

/*
 * SECTION 3: ADDITIONAL METADATA
 */
# define OPENSSL_RELEASE_DATE "xx XXX xxxx"
# define OPENSSL_VERSION_TEXT                                           \
    "OpenSSL " OPENSSL_FULL_VERSION_STR " " OPENSSL_RELEASE_DATE

/*
 * SECTION 3: BACKWARD COMPATIBILITY
 */
# include <openssl/opensslconf.h>

# if !OPENSSL_API_4
/* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PPSL */
#  ifdef OPENSSL_VERSION_PRE_RELEASE
#   define _OPENSSL_VERSION_PRE_RELEASE 0x0
#  else
#   define _OPENSSL_VERSION_PRE_RELEASE 0xf
#  endif
#  define OPENSSL_VERSION_NUMBER        \
          ( (OPENSSL_VERSION_MAJOR<<28)  \
            |(OPENSSL_VERSION_MINOR<<20) \
            |(OPENSSL_VERSION_PATCH<<4)  \
            |_OPENSSL_VERSION_PRE_RELEASE )
# endif

# ifdef  __cplusplus
}
# endif
#endif                          /* HEADER_OPENSSLV_H */```

@sfackler
Copy link
Owner

Are you using openssl git master or something? It looks like we'll need to update to handle the new versioning system.

In the meantime you should be able to use the stable releases of OpenSSL without running into this issue.

@repnop
Copy link
Author

repnop commented Dec 14, 2018

Yeah I should have mentioned its a fresh clone of the repo, I'll give that a try. Thanks :)

@Sinderella
Copy link

Sinderella commented Apr 4, 2019

Are you using openssl git master or something? It looks like we'll need to update to handle the new versioning system.

In the meantime you should be able to use the stable releases of OpenSSL without running into this issue.

Is there any quick workaround for this rather than that? Cheers!

@repnop
Copy link
Author

repnop commented Apr 4, 2019

@Sinderella the OpenSSL repo has their released tagged, so you can checkout to the specific version you want after cloning and that should allow you to build. IIRC that's what I did and it worked 👍

@tux3
Copy link

tux3 commented Jun 23, 2020

Debian Sid now ships libssl-dev 3.0.0~~alpha3-1, so this problem is starting to reach distributions (I just ran into this!)

@sfackler
Copy link
Owner

I'll try to finish off the PR adding 3.0.0 support then: #1264

@sfackler
Copy link
Owner

Given that the alpha releases are still making ABI breaks, I think I'm going to avoid landing that PR until a stable 3.0.0 is released. I'll keep the branch updated so if you need to run against 3.0.0 in the meantime, you can use [patch.crates-io] to switch over to it temporarily.

divanorama added a commit to divanorama/nixpkgs that referenced this issue Nov 16, 2022
Upstream package didn't have recent releases. Currently build fails with something like
```
  running: "/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin/cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/nix/store/f95kxwhnr2bazy7nl6wzwjiak02dlp9v-openssl-3.0.7-dev/include" "-Wall" "-Wextra" "-E" "build/expando.c"
  cargo:warning=build/expando.c:4:24: error: pasting "RUST_VERSION_OPENSSL_" and "(" does not give a valid preprocessing token
  cargo:warning=    4 | #define VERSION2(n, v) RUST_VERSION_##n##_##v
  cargo:warning=      |                        ^~~~~~~~~~~~~
  cargo:warning=build/expando.c:5:23: note: in expansion of macro 'VERSION2'
  cargo:warning=    5 | #define VERSION(n, v) VERSION2(n, v)
  cargo:warning=      |                       ^~~~~~~~
  cargo:warning=build/expando.c:10:1: note: in expansion of macro 'VERSION'
  cargo:warning=   10 | VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
  cargo:warning=      | ^~~~~~~
  exit status: 1
```
which looks like sfackler/rust-openssl#1030
and should be fixed in a transitive dependency by sfackler/rust-openssl#1264

But rather than trying to bump transitive dependency let's downgrade
openssl used by this package.

ZHF: NixOS#199919
@WhyNotHugo
Copy link

WhyNotHugo commented Jun 1, 2023

This is still an issue, nowadays with a stable openssl version.

@LOLCATATONIA
Copy link

You can try fixing this setting the OPENSSL_DIR environment variable

This is occurring on Garuda Linux when trying to build https://github.com/ardeaf/redelete/

OpenSSL 3.2.0 23 Nov 2023 (Library: OpenSSL 3.2.0 23 Nov 2023)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants