google-parfait / federated-compute

Libraries for executing federated programs and computations.
Apache License 2.0
67 stars 18 forks source link

linker error #2

Closed doug-leith closed 1 year ago

doug-leith commented 1 year ago

I commented out the Werror flag in the make files to get past the last issue, but now compilation fails with a linker error:

bazel-out/k8-opt/bin/fcp/client/cache/_objs/file_backed_resource_cache/file_backed_resource_cache.o:file_backed_resource_cache.cc:function fcp::client::cache::FileBackedResourceCache::CleanUp(std::optional, fcp::client::cache::CacheManifest&): error: undefined reference to 'std::filesystem::file_size(std::filesystem::__cxx11::path const&, std::error_code&)'

bazel-out/k8-opt/bin/fcp/client/opstats/_objs/pds_backed_opstats_db/pds_backed_opstats_db.o:pds_backed_opstats_db.cc:function fcp::client::opstats::PdsBackedOpStatsDb::Create(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, absl::lts_20220623::Duration, fcp::client::LogManager&, long): error: undefined reference to 'std::filesystem::__cxx11::path::has_filename() const'

(and many similar errors). looks like the c++ std lib need to be added to the linker options for file_backed_resource_cache.o and pds_backed_opstats_db.o?

doug-leith commented 1 year ago

I think I managed to resolve this by adding:

linkopts=["-lstdc++fs"],

to the "file_backed_resource_cache" cc_library entry in:

federated-compute/fcp/client/cache/BUILD

but maybe there is a nicer fix.

timonvo commented 1 year ago

Thanks for the report. I believe this may be because you're using an older GCC version than we've used when testing out GCC-based builds (I believe the need for -lstdc++fs went away with GCC >=8, when specifying -std=c++17, which our .bazelrc does for all builds; clang also doesn't need that extra flag.).

I'll discuss internally with our team whether to fix this in our code, or whether to update out instructions to recommend a more recent version of GCC.

timonvo commented 1 year ago

Since we try to keep the code buildable with GCC on a best-effort basis only, we decided to not make any changes to the build files and to instead document more clearly that using a recent GCC version might be necessary to build our code. https://github.com/google/federated-compute/commit/2e328fcee285e2cda6a6ca32f6add4fd07c429d0 makes that documentation change. Thanks again for the report!