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

Clang c++ compilation fixes #4739

Merged
merged 11 commits into from Jan 9, 2024
Merged

Conversation

bazsi
Copy link
Collaborator

@bazsi bazsi commented Dec 3, 2023

Let's see if this fixes

#4652

@bazsi bazsi changed the title Clang cxx fixes Clang c++ compilation fixes Dec 3, 2023
@czanik
Copy link
Contributor

czanik commented Dec 4, 2023

RHEL 9 build still fails:

  CXX      modules/grpc/otel/libotel_cpp_la-otel-source.lo
  CXX      modules/grpc/otel/libotel_cpp_la-otel-protobuf-parser.lo
  CXX      modules/grpc/otel/libotel_cpp_la-otel-protobuf-formatter.lo
  CXX      modules/grpc/otel/libotel_cpp_la-otel-dest.lo
  CXX      modules/grpc/otel/libotel_cpp_la-otel-dest-worker.lo
  CXX      modules/grpc/otel/libotel_cpp_la-syslog-ng-otlp-dest.lo
  CXX      modules/grpc/otel/libotel_cpp_la-syslog-ng-otlp-dest-worker.lo
  CXX      modules/grpc/credentials/loki_libloki_cpp_la-grpc-credentials-builder.lo
  CXX      modules/grpc/loki/libloki_cpp_la-loki-dest.lo
  CXX      modules/grpc/loki/libloki_cpp_la-loki-worker.lo
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from ./lib/compat/glib.h:29,
                 from ./lib/syslog-ng.h:35,
                 from modules/grpc/loki/loki-dest.h:28,
                 from modules/grpc/loki/loki-dest.hpp:26,
                 from modules/grpc/loki/loki-dest.cpp:23:
./lib/atomic-gssize.h: In function 'gboolean atomic_gssize_compare_and_exchange(atomic_gssize*, gssize, gssize)':
/usr/include/glib-2.0/glib/gmacros.h:247:38: error: 'remove_reference' in namespace 'std' does not name a template type
  247 | #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
      |                                      ^~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gatomic.h:203:5: note: in expansion of macro 'glib_typeof'
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ^~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:247:54: error: expected unqualified-id before '<' token
  247 | #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
      |                                                      ^
/usr/include/glib-2.0/glib/gatomic.h:203:5: note: in expansion of macro 'glib_typeof'
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ^~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from ./lib/compat/glib.h:29,
                 from ./lib/syslog-ng.h:35,
                 from modules/grpc/loki/loki-dest.h:28,
                 from modules/grpc/loki/loki-dest.hpp:26,
                 from modules/grpc/loki/loki-dest.cpp:23:
/usr/include/glib-2.0/glib/gatomic.h:206:45: error: 'gapcae_oldval' was not declared in this scope
  206 |     __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
      |                                             ^~~~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gatomic.h:201:21: error: void value not ignored as it ought to be
  201 |   (G_GNUC_EXTENSION ({                                                       \
      |   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202 |     G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer));                  \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204 |     G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer));                 \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  205 |     (void) (0 ? (gpointer) *(atomic) : NULL);                                \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206 |     __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  207 |   }))
      |   ~~~                
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from ./lib/compat/glib.h:29,
                 from ./lib/syslog-ng.h:35,
                 from modules/grpc/loki/loki-worker.h:28,
                 from modules/grpc/loki/loki-worker.hpp:26,
                 from modules/grpc/loki/loki-worker.cpp:23:
./lib/atomic-gssize.h: In function 'gboolean atomic_gssize_compare_and_exchange(atomic_gssize*, gssize, gssize)':
/usr/include/glib-2.0/glib/gmacros.h:247:38: error: 'remove_reference' in namespace 'std' does not name a template type
  247 | #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
      |                                      ^~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gatomic.h:203:5: note: in expansion of macro 'glib_typeof'
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ^~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:247:54: error: expected unqualified-id before '<' token
  247 | #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
      |                                                      ^
/usr/include/glib-2.0/glib/gatomic.h:203:5: note: in expansion of macro 'glib_typeof'
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ^~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from ./lib/compat/glib.h:29,
                 from ./lib/syslog-ng.h:35,
                 from modules/grpc/loki/loki-worker.h:28,
                 from modules/grpc/loki/loki-worker.hpp:26,
                 from modules/grpc/loki/loki-worker.cpp:23:
/usr/include/glib-2.0/glib/gatomic.h:206:45: error: 'gapcae_oldval' was not declared in this scope
  206 |     __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
      |                                             ^~~~~~~~~~~~~
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gatomic.h:201:21: error: void value not ignored as it ought to be
  201 |   (G_GNUC_EXTENSION ({                                                       \
      |   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202 |     G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer));                  \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  203 |     glib_typeof (*(atomic)) gapcae_oldval = (oldval);                        \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204 |     G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer));                 \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  205 |     (void) (0 ? (gpointer) *(atomic) : NULL);                                \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206 |     __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  207 |   }))
      |   ~~~                
./lib/atomic-gssize.h:118:10: note: in expansion of macro 'g_atomic_pointer_compare_and_exchange'
  118 |   return g_atomic_pointer_compare_and_exchange(&a->value, oldval, newval);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:27337: modules/grpc/loki/libloki_cpp_la-loki-dest.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:27344: modules/grpc/loki/libloki_cpp_la-loki-worker.lo] Error 1
make[1]: *** [Makefile:28768: all-recursive] Error 1
make: *** [Makefile:12404: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.246MKC (%build)

You can find the full log at https://download.copr.fedorainfracloud.org/results/czanik/syslog-ng-githead/epel-9-x86_64/06722699-syslog-ng/builder-live.log.gz

FreeBSD test will come soon.

@czanik
Copy link
Contributor

czanik commented Dec 4, 2023

FreeBSD CLANG fails:

mv -f ./modules/grpc/protos/google-proto/google/rpc/.deps/modules_grpc_protos_libgrpc_protos_la-status.pb.Tpo ./modules/grpc/protos/google-proto/google/rpc/.deps/modules_grpc_protos_libgrpc_protos_la-status.pb.Plo
/bin/sh ./libtool  --tag=CXX   --mode=link c++ -Wshadow -Wno-stack-protector -Wno-unused-parameter -Wno-variadic-macros   -I/usr/local/include -Wno-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -DNOMINMAX -pthread -I./modules/grpc/protos/googleapis-proto -I./modules/grpc/protos/google-proto -I./modules/grpc/protos/opentelemetry-proto -I./modules/grpc/protos/otlp -I./modules/grpc/protos/grafana-loki -I./modules/grpc/protos/loki  -O2 -g -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -fstack-protector-strong  -o modules/grpc/protos/libgrpc-protos.la -rpath /usr/local/lib ./modules/grpc/protos/otlp/opentelemetry/proto/collector/logs/v1/modules_grpc_protos_libgrpc_protos_la-logs_service.grpc.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/collector/logs/v1/modules_grpc_protos_libgrpc_protos_la-logs_service.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/collector/metrics/v1/modules_grpc_protos_libgrpc_protos_la-metrics_service.grpc.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/collector/metrics/v1/modules_grpc_protos_libgrpc_protos_la-metrics_service.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/collector/trace/v1/modules_grpc_protos_libgrpc_protos_la-trace_service.grpc.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/collector/trace/v1/modules_grpc_protos_libgrpc_protos_la-trace_service.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/common/v1/modules_grpc_protos_libgrpc_protos_la-common.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/logs/v1/modules_grpc_protos_libgrpc_protos_la-logs.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/metrics/v1/modules_grpc_protos_libgrpc_protos_la-metrics.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/resource/v1/modules_grpc_protos_libgrpc_protos_la-resource.pb.lo ./modules/grpc/protos/otlp/opentelemetry/proto/trace/v1/modules_grpc_protos_libgrpc_protos_la-trace.pb.lo ./modules/grpc/protos/loki/modules_grpc_protos_libgrpc_protos_la-push.grpc.pb.lo ./modules/grpc/protos/loki/modules_grpc_protos_libgrpc_protos_la-push.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-annotations.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-client.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-field_behavior.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-http.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-launch_stage.pb.lo ./modules/grpc/protos/google-proto/google/api/modules_grpc_protos_libgrpc_protos_la-resource.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-annotations.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-arrow.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-avro.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-protobuf.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-storage.grpc.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-storage.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-stream.pb.lo ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/modules_grpc_protos_libgrpc_protos_la-table.pb.lo ./modules/grpc/protos/google-proto/google/rpc/modules_grpc_protos_libgrpc_protos_la-status.pb.lo ./lib/libsyslog-ng.la -L/usr/local/lib -lprotobuf -L/usr/local/lib -lgrpc++ -lgrpc -lgpr -labsl_spinlock_wait -labsl_crc32c -labsl_crc_internal -labsl_crc_cpu_detect -labsl_strings_internal -labsl_cordz_functions -labsl_cordz_handle -labsl_graphcycles_internal -labsl_civil_time -labsl_time_zone -labsl_debugging_internal -labsl_demangle_internal -labsl_malloc_internal -labsl_cord_internal -labsl_cordz_info -labsl_crc_cord_state -labsl_bad_optional_access -labsl_flags_program_name -labsl_flags_internal -labsl_log_severity -labsl_str_format_internal -labsl_flags_reflection -labsl_flags_private_handle_accessor -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_city -labsl_bad_variant_access -labsl_low_level_hash -labsl_hashtablez_sampler -labsl_exponential_biased -labsl_throw_delegate -labsl_random_distributions -labsl_random_internal_randen_hwaes -labsl_random_internal_randen_hwaes_impl -labsl_random_internal_randen_slow -labsl_random_internal_platform -labsl_int128 -labsl_random_internal_randen -labsl_random_seed_sequences -labsl_random_internal_pool_urbg -labsl_random_internal_seed_material -labsl_random_seed_gen_exception /usr/lib/libexecinfo.so -labsl_stacktrace -labsl_strerror -labsl_symbolize -labsl_raw_hash_set -labsl_raw_logging_internal -lrt -labsl_base -labsl_cord -labsl_flags -labsl_flags_marshalling -labsl_hash -labsl_status -labsl_statusor -labsl_strings -labsl_synchronization -labsl_time -lstdc++ 
libtool: link: c++  -fPIC -DPIC -shared -nostdlib /usr/lib/crti.o /usr/lib/crtbeginS.o  ./modules/grpc/protos/otlp/opentelemetry/proto/collector/logs/v1/.libs/modules_grpc_protos_libgrpc_protos_la-logs_service.grpc.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/collector/logs/v1/.libs/modules_grpc_protos_libgrpc_protos_la-logs_service.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/collector/metrics/v1/.libs/modules_grpc_protos_libgrpc_protos_la-metrics_service.grpc.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/collector/metrics/v1/.libs/modules_grpc_protos_libgrpc_protos_la-metrics_service.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/collector/trace/v1/.libs/modules_grpc_protos_libgrpc_protos_la-trace_service.grpc.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/collector/trace/v1/.libs/modules_grpc_protos_libgrpc_protos_la-trace_service.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/common/v1/.libs/modules_grpc_protos_libgrpc_protos_la-common.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/logs/v1/.libs/modules_grpc_protos_libgrpc_protos_la-logs.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/metrics/v1/.libs/modules_grpc_protos_libgrpc_protos_la-metrics.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/resource/v1/.libs/modules_grpc_protos_libgrpc_protos_la-resource.pb.o ./modules/grpc/protos/otlp/opentelemetry/proto/trace/v1/.libs/modules_grpc_protos_libgrpc_protos_la-trace.pb.o ./modules/grpc/protos/loki/.libs/modules_grpc_protos_libgrpc_protos_la-push.grpc.pb.o ./modules/grpc/protos/loki/.libs/modules_grpc_protos_libgrpc_protos_la-push.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-annotations.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-client.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-field_behavior.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-http.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-launch_stage.pb.o ./modules/grpc/protos/google-proto/google/api/.libs/modules_grpc_protos_libgrpc_protos_la-resource.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-annotations.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-arrow.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-avro.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-protobuf.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-storage.grpc.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-storage.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-stream.pb.o ./modules/grpc/protos/google-proto/google/cloud/bigquery/storage/v1/.libs/modules_grpc_protos_libgrpc_protos_la-table.pb.o ./modules/grpc/protos/google-proto/google/rpc/.libs/modules_grpc_protos_libgrpc_protos_la-status.pb.o   -Wl,-rpath -Wl,/root/syslog-ng-grpc/work/syslog-ng-4.5.0.48.gad9c376/lib/.libs -Wl,-rpath -Wl,/usr/local/lib ./lib/.libs/libsyslog-ng.so -L/usr/local/lib -lprotobuf -lgrpc++ -lgrpc -lgpr -labsl_spinlock_wait -labsl_crc32c -labsl_crc_internal -labsl_crc_cpu_detect -labsl_strings_internal -labsl_cordz_functions -labsl_cordz_handle -labsl_graphcycles_internal -labsl_civil_time -labsl_time_zone -labsl_debugging_internal -labsl_demangle_internal -labsl_malloc_internal -labsl_cord_internal -labsl_cordz_info -labsl_crc_cord_state -labsl_bad_optional_access -labsl_flags_program_name -labsl_flags_internal -labsl_log_severity -labsl_str_format_internal -labsl_flags_reflection -labsl_flags_private_handle_accessor -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_city -labsl_bad_variant_access -labsl_low_level_hash -labsl_hashtablez_sampler -labsl_exponential_biased -labsl_throw_delegate -labsl_random_distributions -labsl_random_internal_randen_hwaes -labsl_random_internal_randen_hwaes_impl -labsl_random_internal_randen_slow -labsl_random_internal_platform -labsl_int128 -labsl_random_internal_randen -labsl_random_seed_sequences -labsl_random_internal_pool_urbg -labsl_random_internal_seed_material -labsl_random_seed_gen_exception -labsl_stacktrace -labsl_strerror -labsl_symbolize -labsl_raw_hash_set -labsl_raw_logging_internal -lrt -labsl_base -labsl_cord -labsl_flags -labsl_flags_marshalling -labsl_hash -labsl_status -labsl_statusor -labsl_strings -labsl_synchronization -labsl_time -lstdc++ -L/usr/lib -lc++ -lm -lc -lgcc -lgcc_s /usr/lib/crtendS.o /usr/lib/crtn.o  -O2 -g -O2 -fstack-protector-strong -fstack-protector-strong   -pthread -Wl,-soname -Wl,libgrpc-protos.so.0 -o modules/grpc/protos/.libs/libgrpc-protos.so.0.0.0
c++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: error: unable to find library -lstdc++
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[4]: *** [Makefile:14900: modules/grpc/protos/libgrpc-protos.la] Error 1
gmake[3]: *** [Makefile:28768: all-recursive] Error 1
gmake[2]: *** [Makefile:12404: all] Error 2
gmake[2]: Leaving directory '/root/syslog-ng-grpc/work/syslog-ng-4.5.0.48.gad9c376'
*** Error code 1

Most likely because it has c++, but no libstdc++, according to the output of find.

Next up: trying gcc on FreeBSD again.

@czanik
Copy link
Contributor

czanik commented Dec 4, 2023

Using GCC it compiles, but some modules fail to load:

root@fb132:~/syslog-ng-grpc # syslog-ng -V
syslog-ng 4 (4.5.0.48.gad9c376)
Config version: 4.2
Installer-Version: 4.5.0.48.gad9c376
Revision: 
Compile-Date: Dec  4 2023 16:43:50
Module-Directory: /usr/local/lib/syslog-ng
Module-Path: /usr/local/lib/syslog-ng
Include-Path: /usr/local/share/syslog-ng/include
Error opening plugin module; module='loki', error='/usr/local/lib/libgrpc-protos.so.0: Undefined symbol "_ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev"'
Error opening plugin module; module='otel', error='/usr/local/lib/syslog-ng/libotel.so: Undefined symbol "_ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx11E"'
Available-Modules: http,json-plugin,add-contextual-data,affile,afprog,afsocket,afstomp,afuser,appmodel,azure-auth-header,basicfuncs,cef,confgen,cryptofuncs,csvparser,correlation,disk-buffer,examples,graphite,hook-commands,kvformat,linux-kmsg-format,map-value-pairs,metrics-probe,pseudofile,regexp-parser,secure-logging,stardate,syslogformat,system-source,tags-parser,tfgetent,timestamp,xml,rate-limit-filter
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: off
Enable-TCP-Wrapper: off
Enable-Linux-Caps: off
Enable-Systemd: off

@czanik
Copy link
Contributor

czanik commented Dec 4, 2023

OK. I'm not a programmer, so I might write something stupid :-) It seems that FreeBSD has clang and uses libc++, while gcc has libstdc++. They are not fully compatible. Software compiled with one cannot be properly linked with the other one. The following option could make sure that syslog-ng uses libc++ instead of libstdc++

       -stdlib=<library>
              Specify the C++ standard library to use; supported options are
              libstdc++ and libc++. If not specified, platform default will be
              used.

@czanik
Copy link
Contributor

czanik commented Dec 4, 2023

OK. I did a bit of experimenting. Replacing all occurrences of stdc++ with c++ in code helps a lot. At least syslog-ng does not throw an error on syslog-ng -V:

[root@fb132 ~/syslog-ng-grpc]# syslog-ng -V
syslog-ng 4 (4.5.0.48.gad9c376)
Config version: 4.2
Installer-Version: 4.5.0.48.gad9c376
Revision: 
Compile-Date: Dec  4 2023 18:09:44
Module-Directory: /usr/local/lib/syslog-ng
Module-Path: /usr/local/lib/syslog-ng
Include-Path: /usr/local/share/syslog-ng/include
Available-Modules: http,loki,otel,json-plugin,add-contextual-data,affile,afprog,afsocket,afstomp,afuser,appmodel,azure-auth-header,basicfuncs,cef,confgen,cryptofuncs,csvparser,correlation,disk-buffer,examples,graphite,hook-commands,kvformat,linux-kmsg-format,map-value-pairs,metrics-probe,pseudofile,regexp-parser,secure-logging,stardate,syslogformat,system-source,tags-parser,tfgetent,timestamp,xml,rate-limit-filter
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: off
Enable-TCP-Wrapper: off
Enable-Linux-Caps: off
Enable-Systemd: off

All I did was:

grep -Rl stdc++ * > 1

and

for i in `cat 1` ; do sed -i czp 's/stdc++/c++/g' $i ; done

So, it seems that I found the solution for my favorite OS, FreeBSD. However, a lot more users run RHEL, and RHEL 9 is getting popular...

@bazsi
Copy link
Collaborator Author

bazsi commented Dec 6, 2023

I was just wondering how we got that the g_pointer_atomic_*() functions support anything but pointers? Because we passing a gssize to them at the moment.

@MrAnno do you have a recollection of that?

@MrAnno
Copy link
Collaborator

MrAnno commented Dec 6, 2023

We wanted 64-bit stats counters wherever they are available, so we implemented atomic_gssize on top of atomic pointers. There is a static assertion making sure that the size of gssize matches the size of a void pointer.

@MrAnno
Copy link
Collaborator

MrAnno commented Dec 6, 2023

The same is true for LogSource window trackers. We needed the first bit of the window to make sure that "forced suspending" (disk-buffer) remains atomic for real.

@bazsi
Copy link
Collaborator Author

bazsi commented Dec 6, 2023

Just pushed an alternative solution. This should trigger a lot of compilation warnings but should let syslog-ng compile. Details: https://gitlab.gnome.org/GNOME/glib/-/issues/3193#note_1935964

@czanik can you please check if his indeed compiles on RHEL9?

The FreeBSD issue is separate, if you compile with gcc the issue is that your protobuf libraries are compiled with clang and that causes the linker error. Actually you get the same issue with clang but it errors out instead of simply generating an invalid binary. The right solution is indeed to link against -lc++ instead of -lstdc++ but we would need to detect somehow which one is the right one.

@kira-syslogng
Copy link
Contributor

Build FAILURE

@czanik
Copy link
Contributor

czanik commented Dec 6, 2023

@bazsi Thanks! I'm still waiting for the Fedora / RHEL builds, but (open)SUSE build results are already available. This patch breaks SLES 12 SP5:

[   27s] checking for glib-2.0 >= 2.32 gmodule-2.0 gthread-2.0... yes
[   27s] checking for g_list_copy_deep... yes
[   27s] checking for g_ptr_array_find_with_equal_func... no
[   27s] checking for g_canonicalize_filename... no
[   27s] checking sanity checking Glib headers... no
[   27s] configure: error: Glib headers inconsistent with current compiler setting. You might be using 32 bit Glib with a 64 bit compiler, check PKG_CONFIG_PATH
[   28s] error: Bad exit status from /var/tmp/rpm-tmp.9BiXoz (%build)

@czanik
Copy link
Contributor

czanik commented Dec 6, 2023

And it breaks RHEL 7 and RHEL 8 builds with the same error message. Still waiting for RHEL 9...

@czanik
Copy link
Contributor

czanik commented Dec 6, 2023

@bazsi
Copy link
Collaborator Author

bazsi commented Dec 7, 2023

centos7 and sles sp5 breaks as they don't have glib 2.68 which this PR would start depending on.

@bazsi
Copy link
Collaborator Author

bazsi commented Dec 7, 2023

I've tried to fix up centos7. let's see if that works.

@kira-syslogng
Copy link
Contributor

Build FAILURE

@bazsi bazsi force-pushed the clang-cxx-fixes branch 2 times, most recently from eb49322 to 4df8bd3 Compare December 7, 2023 11:58
@kira-syslogng
Copy link
Contributor

Build FAILURE

@bazsi bazsi force-pushed the clang-cxx-fixes branch 2 times, most recently from d9e8357 to 1172f43 Compare December 8, 2023 23:07
@kira-syslogng
Copy link
Contributor

Build FAILURE

@HofiOne
Copy link
Collaborator

HofiOne commented Jan 3, 2024

This seems to be the VERSION file in the root of syslog-ng. but that's all caps e.g. "VERSION" and not "version"

Yepp, we discussed this one once with @alltilla, not an easy fix as a bunch of build stuff depends on this (CI, PE)

@alltilla
Copy link
Collaborator

alltilla commented Jan 3, 2024

Yes the macOS filename case insensitivity is what tricks us here, I believe.

@HofiOne
Copy link
Collaborator

HofiOne commented Jan 4, 2024

Yes the macOS filename case insensitivity is what tricks us here, I believe.

@bazsi , @alltilla

I finally got a working build of GRPC dependant modules (so basically now all the c++ modules) on macOS as well

2 questions

  1. it seems libgrpc-protos.dylib got referenced in the otel and the bigquery modules from
    install/lib/libgrpc-protos.dylib
    intead of
    install/lib/syslog-ng/libgrpc-protos.dylib
    or the libgrpc-protos.dylib lib is installed to an incorrect location (install/lib/syslog-ng/)
    which one is the required here?

  2. it seems the VERSION file in the root folder of the syslog-ng repository is used only during the packaging flows
    is this true?
    (i just simply renamed the file, clean built everything and the build was successful, syslog-ng --version shows a correct version number)

@HofiOne
Copy link
Collaborator

HofiOne commented Jan 8, 2024

2. it seems the `VERSION` file in the root folder of the syslog-ng repository is used only during the packaging flows
   is this true?
   (i just simply renamed the file, clean built everything and the build was successful, `syslog-ng --version` shows a correct version number)

no2. is solved by #4775

@alltilla
Copy link
Collaborator

alltilla commented Jan 8, 2024

Rebased to master and resolved the merge conflicts.

@alltilla alltilla added this to the syslog-ng 4.6 milestone Jan 9, 2024
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…tring functions

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
cr_assert() would expect arguments to the format string but they were
not supplied. clang warns about this.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
clang complained about an unreferenced local variable in the generated
grammar.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Not all warnings are supported everywhere, so check their presence from
configure.ac before using them in Makefile.am.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
This makes sure syslog-ng.h and glib.h are included from outside
of extern "C" blocks.

 * Header ordering:
 *   - syslog-ng.h needs to come first even in cpp/hpp files.  You don't
 *     need cpp-start/end wrapper around syslog-ng.h.  This include can
 *     happen indirectly, e.g.  if you include any other header that should
 *     take care of syslog-ng.h
 *
 *   - syslog-ng.h will include glib too, which is also C++ safe.  This is
 *     needed as some constructs in glib only work if it is outside of an
 *     extern "C" block.
 *
 *   - Use the usual header ordering conventions, e.g.  include the closest
 *     header first (e.g.  the one associated with your module) and then
 *     iterate to furthest.  This ensures that each header is actually
 *     standalone and includes all its dependencies.
 *
 *   - If you use a .hpp file, include .h from it and make sure the .h
 *     includes syslog-ng.h and includes all other .h files by wrapping them
 *     using cpp-start/end.h as needed. This takes care of the first rule.
 *
 *   - In your .cpp files, include the .hpp file but not the .h file which is
 *     already included.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…ecent glib

This fixes clang++ compilation as explained here:
  https://gitlab.gnome.org/GNOME/glib/-/issues/3193#note_1935964

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…er associated with CC

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
@alltilla
Copy link
Collaborator

alltilla commented Jan 9, 2024

Rebased to master.

@alltilla alltilla merged commit d7c8116 into syslog-ng:master Jan 9, 2024
20 checks passed
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

Successfully merging this pull request may close these issues.

None yet

6 participants