Skip to content

pkgconfig glib fails with goption.c:169:14: error: two or more data types in declaration specifiers #1427

@baryluk

Description

@baryluk

Using rules_foreign_cc 0.15.1, (it was working fine with 0.12.0 I think), on Fedora 42 (gcc 15.1.1), and bazel 7.4.1

WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository", "git_repository")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

# rules_python_version = "0.37.2"
# rules_python_version = "0.38.0"
# rules_python_version = "1.4.1"
rules_python_version = "1.5.0-rc4"
rules_python_SHA256 = {
    "0.37.2": "c6fb25d0ba0246f6d5bd820dd0b2e66b339ccc510242fd4956b9a639b548d113",  # 2024-10-27
    "0.38.0": "ca2671529884e3ecb5b79d6a5608c7373a82078c3553b1fa53206e6b9dddab34",  # 2024-11-08
    "1.4.1": "9f9f3b300a9264e4c77999312ce663be5dee9a56e361a1f6fe7ec60e1beef9a3",  # 2025-05-08
    "1.5.0-rc4": "8b98bfab75cd469bd5f9b63dc48a2f652b0348880006e5cb8299f4ee04292a95",  # 2025-06-26
}
http_archive(
    name = "rules_python",
    sha256 = rules_python_SHA256.get(rules_python_version) or None,
    strip_prefix = "rules_python-" + rules_python_version,
    # url = "https://github.com/bazelbuild/rules_python/releases/download/" + rules_python_version + "/rules_python-" + rules_python_version + ".tar.gz",
    url = "https://github.com/bazel-contrib/rules_python/releases/download/" + rules_python_version + "/rules_python-" + rules_python_version + ".tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
    name = "python_3_12",
    python_version = "3.12.11",
    ignore_root_user_error = True,
)
# rules_foreign_cc_version = "0.9.0"
# rules_foreign_cc_version = "0.12.0"
rules_foreign_cc_version = "0.15.1"
rules_foreign_cc_SHA256 = {
    "0.9.0": "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
    "0.12.0": "a2e6fb56e649c1ee79703e99aa0c9d13c6cc53c8d7a0cbb8797ab2888bbc99a3",
    "0.15.1": "32759728913c376ba45b0116869b71b68b1c2ebf8f2bcf7b41222bc07b773d73",
}
http_archive(
    name = "rules_foreign_cc",
    url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/" + rules_foreign_cc_version + ".tar.gz",
    sha256 = rules_foreign_cc_SHA256.get(rules_foreign_cc_version) or None,
    strip_prefix = "rules_foreign_cc-" + rules_foreign_cc_version,
)
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()

# ...
# ...

Output:

...
...
ERROR: /home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/external/rules_foreign_cc/toolchains/private/BUILD.bazel:158:15: BootstrapPkgConfig external/rules_foreign_cc/toolchains/private/pkgconfig [for tool] failed: (Exit 2): bash failed: error executing BootstrapPkgConfig command (from target @@rules_foreign_cc//toolchains/private:pkgconfig_tool_default) /bin/bash -c bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/pkgconfig_tool_default_foreign_cc/wrapper_build_script.sh

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
rules_foreign_cc: Build failed!
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ ZERO_AR_DATE=1
+ AR=/usr/bin/ar
+ ARFLAGS=
+ CC=/usr/bin/gcc
+ CFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=\\"redacted\\" -D__TIMESTAMP__=\\"redacted\\" -D__TIME__=\\"redacted\\" -Wno-int-conversion'
+ LD=/usr/bin/gcc
+ LDFLAGS='-Wl,-S -fuse-ld=lld -B/usr/bin -Wl,-no-as-needed -Wl,-z,relro,-z,now -pass-exit-codes -Wl,--gc-sections -Wl,--push-state,-as-needed -lstdc++ -Wl,--pop-state -Wl,--push-state,-as-needed -lm -Wl,--pop-state'
+ MAKE=/home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/sandbox/linux-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/make/bin/make
+ ./configure --with-internal-glib --prefix=/home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/sandbox/linux-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/pkgconfig
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether /home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/sandbox/linux-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/make/bin/make sets $(MAKE)... yes
checking whether /home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/sandbox/linux-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/make/bin/make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by /home/witek/.cache/bazel/_bazel_witek/6aae031749570f5eb9f52e7c0b66981f/sandbox/linux-sandbox/1/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_foreign_cc/toolchains/private/make/bin/make... GNU
checking for gcc... /usr/bin/gcc

...
...

  CC       libglib_2_0_la-gerror.lo
  CC       libglib_2_0_la-gfileutils.lo
  CC       libglib_2_0_la-ggettext.lo
In file included from ggettext.c:30:
ggettext.c: In function 'ensure_gettext_initialized':
glibintl.h:37:42: warning: statement with no effect [-Wunused-value]
   37 | #define bindtextdomain(Domain,Directory) (Domain)
      |                                          ^
ggettext.c:109:7: note: in expansion of macro 'bindtextdomain'
  109 |       bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
      |       ^~~~~~~~~~~~~~
  CC       libglib_2_0_la-ghash.lo
  CC       libglib_2_0_la-ghmac.lo
  CC       libglib_2_0_la-ghook.lo
  CC       libglib_2_0_la-ghostutils.lo
  CC       libglib_2_0_la-giochannel.lo
  CC       libglib_2_0_la-gkeyfile.lo
  CC       libglib_2_0_la-glib-init.lo
  CC       libglib_2_0_la-glib-private.lo
  CC       libglib_2_0_la-glist.lo
  CC       libglib_2_0_la-gmain.lo
  CC       libglib_2_0_la-gmappedfile.lo
  CC       libglib_2_0_la-gmarkup.lo
  CC       libglib_2_0_la-gmem.lo
  CC       libglib_2_0_la-gmessages.lo
  CC       libglib_2_0_la-gnode.lo
  CC       libglib_2_0_la-goption.lo
goption.c:169:14: error: two or more data types in declaration specifiers
  169 |     gboolean bool;
      |              ^~~~
goption.c:169:18: warning: declaration does not declare anything
  169 |     gboolean bool;
      |                  ^
goption.c: In function 'free_changes_list':
goption.c:1603:60: error: expected identifier before 'bool'
 1603 |               *(gboolean *)change->arg_data = change->prev.bool;
      |                                                            ^~~~
make[6]: *** [Makefile:1541: libglib_2_0_la-goption.lo] Error 1

There is also a number of small warnings (about unused return values, from fgets, dup (o!), and write), but they do not appear to necessarily cause immediate trouble.

I do pass a bunch of extra flags to compiler (usually via BAZEL_CXXOPTS action_env), i.e. to change c++ standard, and enable bunch of warnings (in fact all, then disable some that cause trouble in dependencies). But I do not see any option I change that would affect C standard.

GCC 15 does enable C23 by default as C standard, instead of C17 as in previous version. And that does enable bunch of keywords like bool that cause that issue, and few other minor changes.

Passing --conlyopt=-std=gnu17 to bazel build does not help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions