rocksdb/options
Peter Dillinger e24734f843 Use -Wno-invalid-offsetof instead of dangerous offset_of hack (#9563)
Summary:
After https://github.com/facebook/rocksdb/issues/9515 added a unique_ptr to Status, we see some
warnings-as-error in some internal builds like this:

```
stderr: rocksdb/src/db/compaction/compaction_job.cc:2839:7: error:
offset of on non-standard-layout type 'struct CompactionServiceResult'
[-Werror,-Winvalid-offsetof]
     {offsetof(struct CompactionServiceResult, status),
      ^                                        ~~~~~~
```

I see three potential solutions to resolving this:

* Expand our use of an idiom that works around the warning (see offset_of
functions removed in this change, inspired by
https://gist.github.com/graphitemaster/494f21190bb2c63c5516)  However,
this construction is invoking undefined behavior that assumes consistent
layout with no compiler-introduced indirection. A compiler incompatible
with our assumptions will likely compile the code and exhibit undefined
behavior.
* Migrate to something in place of offset, like a function mapping
CompactionServiceResult* to Status* (for the `status` field). This might
be required in the long term.
* **Selected:** Use our new C++17 dependency to use offsetof in a well-defined way
when the compiler allows it. From a comment on
https://gist.github.com/graphitemaster/494f21190bb2c63c5516:

> A final note: in C++17, offsetof is conditionally supported, which
> means that you can use it on any type (not just standard layout
> types) and the compiler will error if it can't compile it correctly.
> That appears to be the best option if you can live with C++17 and
> don't need constexpr support.

The C++17 semantics are confirmed on
https://en.cppreference.com/w/cpp/types/offsetof, so we can suppress the
warning as long as we accept that we might run into a compiler that
rejects the code, and at that point we will find a solution, such as
the more intrusive "migrate" solution above.

Although this is currently only showing in our buck build, it will
surely show up also with make and cmake, so I have updated those
configurations as well.

Also in the buck build, -Wno-expansion-to-defined does not appear to be
needed anymore (both current compiler configurations) so I
removed it.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9563

Test Plan: Tried out buck builds with both current compiler configurations

Reviewed By: riversand963

Differential Revision: D34220931

Pulled By: pdillinger

fbshipit-source-id: d39436008259bd1eaaa87c77be69fb2a5b559e1f
2022-02-15 09:19:19 -08:00
..
cf_options.cc Use -Wno-invalid-offsetof instead of dangerous offset_of hack (#9563) 2022-02-15 09:19:19 -08:00
cf_options.h Remove unused option purge_redundant_kvs_while_flush (#9429) 2022-01-26 10:24:16 -08:00
configurable_helper.h Fix some minor issues in the Customizable infrastructure (#8566) 2021-08-19 10:10:47 -07:00
configurable_test.cc Fix GetOptionsPtr for Wrapped Customizable; Allow null options map (#9213) 2021-11-30 13:23:25 -08:00
configurable_test.h Move RegisterOptions into the Configurable API (#8223) 2021-04-26 03:13:24 -07:00
configurable.cc Fix an issue with MemTableRepFactory::CreateFromString (#9273) 2021-12-09 12:36:18 -08:00
customizable_test.cc Use -Wno-invalid-offsetof instead of dangerous offset_of hack (#9563) 2022-02-15 09:19:19 -08:00
customizable.cc Add support to the ObjectRegistry for ManagedObjects (#8658) 2021-09-10 05:21:04 -07:00
db_options.cc Remove deprecated option new_table_reader_for_compaction_inputs (#9443) 2022-02-08 19:31:28 -08:00
db_options.h Remove deprecated option new_table_reader_for_compaction_inputs (#9443) 2022-02-08 19:31:28 -08:00
options_helper.cc Remove deprecated option new_table_reader_for_compaction_inputs (#9443) 2022-02-08 19:31:28 -08:00
options_helper.h Make bottommost_temperature dynamically changeable (#9402) 2022-01-25 15:23:04 -08:00
options_parser.cc Allow unregistered options to be ignored in DBOptions from files (#9045) 2021-10-19 10:43:04 -07:00
options_parser.h Bring the Configurable options together (#5753) 2020-09-14 17:01:01 -07:00
options_settable_test.cc Use -Wno-invalid-offsetof instead of dangerous offset_of hack (#9563) 2022-02-15 09:19:19 -08:00
options_test.cc Hide deprecated, inefficient block-based filter from public API (#9535) 2022-02-12 07:05:57 -08:00
options.cc Remove deprecated API AdvancedColumnFamilyOptions::rate_limit_delay_max_milliseconds (#9455) 2022-01-28 16:47:08 -08:00