Skip to content

CDRIVER-2813 remove BSON_EXTRA_ALIGNMENT option #1942

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

Merged
merged 12 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .evergreen/config_generator/components/loadbalanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def tasks():
env={
'CC': _COMPILER,
'CFLAGS': '-fno-omit-frame-pointer',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF',
'SSL': 'OPENSSL'
},
working_dir='mongoc',
Expand Down
1 change: 0 additions & 1 deletion .evergreen/config_generator/components/mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def variants():
'CC': 'gcc',
'ASAN': 'on',
'CFLAGS': '-fno-omit-frame-pointer',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF',
'SANITIZE': 'address,undefined',
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def variants():
'ASAN': 'on',
'CFLAGS': '-fno-omit-frame-pointer',
'CHECK_LOG': 'ON',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF',
'SANITIZE': 'address,undefined',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def variants():
expansions = {
'CFLAGS': '-fno-omit-frame-pointer',
'CHECK_LOG': 'ON',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_SHM_COUNTERS=OFF',
'SANITIZE': 'thread',
}

Expand Down
30 changes: 1 addition & 29 deletions .evergreen/generated_configs/legacy-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,6 @@ tasks:
set -o errexit
env SNAPPY="OFF" ZLIB="OFF" ZSTD="ON" .evergreen/scripts/compile.sh
- func: upload-build
- name: debug-compile-no-align
tags:
- debug-compile
commands:
- func: find-cmake-latest
- command: shell.exec
type: test
params:
working_dir: mongoc
add_expansions_to_env: true
shell: bash
script: |-
set -o errexit
env EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF" SNAPPY="OFF" ZLIB="BUNDLED" ZSTD="OFF" .evergreen/scripts/compile.sh
- func: upload-build
- name: debug-compile-nosasl-nossl
tags:
- debug-compile
Expand Down Expand Up @@ -1311,7 +1296,7 @@ tasks:
shell: bash
script: |-
set -o errexit
env SANITIZE=address SASL=AUTO SSL=OPENSSL EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF' .evergreen/scripts/compile.sh
env SANITIZE=address SASL=AUTO SSL=OPENSSL .evergreen/scripts/compile.sh
- func: prepare-kerberos
- func: run auth tests
vars:
Expand Down Expand Up @@ -16373,7 +16358,6 @@ buildvariants:
tasks:
- release-compile
- debug-compile-nosasl-nossl
- debug-compile-no-align
- .debug-compile !.sspi .nossl .nosasl
- .latest .nossl .nosasl
- name: gcc82rhel
Expand Down Expand Up @@ -16417,7 +16401,6 @@ buildvariants:
tasks:
- release-compile
- debug-compile-nosasl-nossl
- debug-compile-no-align
- .latest .nossl .nosasl
- name: gcc94
display_name: GCC 9.4 (Ubuntu 20.04)
Expand All @@ -16429,7 +16412,6 @@ buildvariants:
- debug-compile-nosrv
- release-compile
- debug-compile-nosasl-nossl
- debug-compile-no-align
- debug-compile-sasl-openssl
- debug-compile-nosasl-openssl
- .authentication-tests .openssl
Expand All @@ -16449,7 +16431,6 @@ buildvariants:
- .compression !.snappy
- release-compile
- debug-compile-nosasl-nossl
- debug-compile-no-align
- debug-compile-nosrv
- debug-compile-sasl-darwinssl
- debug-compile-nosasl-nossl
Expand Down Expand Up @@ -16507,13 +16488,6 @@ buildvariants:
tasks:
- debug-compile-nosasl-nossl
- .latest .nossl .nosasl .server
- name: mingw
display_name: MinGW-W64
expansions:
CC: mingw
run_on: windows-vsCurrent-large
tasks:
- debug-compile-no-align
- name: rhel8-power
display_name: Power (ppc64le) (RHEL 8)
expansions:
Expand All @@ -16534,7 +16508,6 @@ buildvariants:
run_on: ubuntu2004-arm64-large
tasks:
- .compression !.snappy !.zstd
- debug-compile-no-align
- release-compile
- debug-compile-nosasl-nossl
- debug-compile-nosasl-openssl
Expand All @@ -16550,7 +16523,6 @@ buildvariants:
run_on: rhel8-zseries-large
tasks:
- release-compile
- debug-compile-no-align
- debug-compile-nosasl-nossl
- debug-compile-nosasl-openssl
- debug-compile-sasl-openssl
Expand Down
1 change: 0 additions & 1 deletion .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,6 @@ tasks:
env:
CC: gcc
CFLAGS: -fno-omit-frame-pointer
EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF
SSL: OPENSSL
args:
- -c
Expand Down
4 changes: 1 addition & 3 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ buildvariants:
ASAN: "on"
CC: gcc
CFLAGS: -fno-omit-frame-pointer
EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF
SANITIZE: address,undefined
tasks:
- name: mock-server-test
Expand All @@ -194,7 +193,6 @@ buildvariants:
ASAN: "on"
CFLAGS: -fno-omit-frame-pointer
CHECK_LOG: "ON"
EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF
SANITIZE: address,undefined
tasks:
- name: .sanitizers-matrix-asan
Expand All @@ -203,7 +201,7 @@ buildvariants:
expansions:
CFLAGS: -fno-omit-frame-pointer
CHECK_LOG: "ON"
EXTRA_CONFIGURE_FLAGS: -DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF
EXTRA_CONFIGURE_FLAGS: -DENABLE_SHM_COUNTERS=OFF
SANITIZE: thread
tasks:
- name: .sanitizers-matrix-tsan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class CompileWithClientSideEncryptionAsan(CompileTask):
CFLAGS="-fno-omit-frame-pointer",
COMPILE_LIBMONGOCRYPT="ON",
CHECK_LOG="ON",
EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF",
PATH="/usr/lib/llvm-3.8/bin:$PATH",
)
cls_tags: ClassVar[Sequence[str]] = ["client-side-encryption"]
Expand Down Expand Up @@ -187,12 +186,6 @@ def __init__(
CompileTask("debug-compile-compression-zlib", tags=["zlib", "compression"], compression="zlib"),
CompileTask("debug-compile-compression-snappy", tags=["snappy", "compression"], compression="snappy"),
CompileTask("debug-compile-compression-zstd", tags=["zstd", "compression"], compression="zstd"),
CompileTask(
"debug-compile-no-align",
tags=["debug-compile"],
compression="zlib",
EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF",
),
CompileTask("debug-compile-nosasl-nossl", tags=["debug-compile", "nosasl", "nossl"], SSL="OFF"),
CompileTask("debug-compile-lto", CFLAGS="-flto"),
CompileTask("debug-compile-lto-thin", CFLAGS="-flto=thin"),
Expand Down Expand Up @@ -697,7 +690,7 @@ def pre_commands(self) -> Iterable[Value]:
func("find-cmake-latest"),
shell_mongoc(
"""
env SANITIZE=address SASL=AUTO SSL=OPENSSL EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF' .evergreen/scripts/compile.sh
env SANITIZE=address SASL=AUTO SSL=OPENSSL .evergreen/scripts/compile.sh
""",
add_expansions_to_env=True,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def days(n: int) -> int:
[
"release-compile",
"debug-compile-nosasl-nossl",
"debug-compile-no-align",
".debug-compile !.sspi .nossl .nosasl",
".latest .nossl .nosasl",
],
Expand Down Expand Up @@ -151,7 +150,7 @@ def days(n: int) -> int:
"gcc94-i686",
"GCC 9.4 (i686) (Ubuntu 20.04)",
"ubuntu2004-test",
["release-compile", "debug-compile-nosasl-nossl", "debug-compile-no-align", ".latest .nossl .nosasl"],
["release-compile", "debug-compile-nosasl-nossl", ".latest .nossl .nosasl"],
{"CC": "gcc", "MARCH": "i686"},
),
Variant(
Expand All @@ -163,7 +162,6 @@ def days(n: int) -> int:
"debug-compile-nosrv",
"release-compile",
"debug-compile-nosasl-nossl",
"debug-compile-no-align",
"debug-compile-sasl-openssl",
"debug-compile-nosasl-openssl",
".authentication-tests .openssl",
Expand All @@ -185,7 +183,6 @@ def days(n: int) -> int:
".compression !.snappy",
"release-compile",
"debug-compile-nosasl-nossl",
"debug-compile-no-align",
"debug-compile-nosrv",
"debug-compile-sasl-darwinssl",
"debug-compile-nosasl-nossl",
Expand Down Expand Up @@ -250,7 +247,6 @@ def days(n: int) -> int:
["debug-compile-nosasl-nossl", ".latest .nossl .nosasl .server"],
{"CC": "mingw"},
),
Variant("mingw", "MinGW-W64", "windows-vsCurrent-large", ["debug-compile-no-align"], {"CC": "mingw"}),
Variant(
"rhel8-power",
"Power (ppc64le) (RHEL 8)",
Expand All @@ -272,7 +268,6 @@ def days(n: int) -> int:
"ubuntu2004-arm64-large",
[
".compression !.snappy !.zstd",
"debug-compile-no-align",
"release-compile",
"debug-compile-nosasl-nossl",
"debug-compile-nosasl-openssl",
Expand All @@ -291,7 +286,6 @@ def days(n: int) -> int:
[
"release-compile",
# '.compression', --> TODO: waiting on ticket CDRIVER-3258
"debug-compile-no-align",
"debug-compile-nosasl-nossl",
"debug-compile-nosasl-openssl",
"debug-compile-sasl-openssl",
Expand Down
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,6 @@ mongo_bool_setting(
]]
)

# Deprecated options:
mongo_bool_setting(
ENABLE_EXTRA_ALIGNMENT
"[Deprecated] Enable extra alignment on libbson types"
DEFAULT VALUE ON
DEVEL VALUE OFF
VALIDATE CODE [[
if(ENABLE_EXTRA_ALIGNMENT AND MONGO_SANITIZE MATCHES "undefined")
message(WARNING "ENABLE_EXTRA_ALIGNMENT=“${ENABLE_EXTRA_ALIGNMENT}” will create conflicts with UndefinedBehaviorSanitizer")
endif()
]]
)

# Announce the build configuration. Used by `mlib_build_config_is()` in `mlib/config.h`
add_compile_definitions(_MLIB_BUILD_CONFIG=$<CONFIG>)

Expand Down Expand Up @@ -302,8 +289,6 @@ if ( (ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR S
set (ENABLE_BUILD_DEPENDECIES ON)
endif ()

mongo_pick(BSON_EXTRA_ALIGN 1 0 ENABLE_EXTRA_ALIGNMENT)

mongo_pick(MONGOC_ENABLE_RDTSCP 1 0 ENABLE_RDTSCP)

mongo_pick(MONGOC_ENABLE_STATIC_BUILD 1 0 ENABLE_STATIC)
Expand Down
1 change: 0 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ build:
RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \
-D ENABLE_MAINTAINER_FLAGS=ON \
-D ENABLE_SHM_COUNTERS=ON \
-D ENABLE_EXTRA_ALIGNMENT=OFF \
-D ENABLE_SASL=$(echo $sasl | __str upper) \
-D ENABLE_SNAPPY=ON \
-D ENABLE_SRV=ON \
Expand Down
5 changes: 5 additions & 0 deletions src/libbson/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ libbson 2.0.0 (Unreleased)
* Compiling with `BSON_MEMCHECK` defined now has no effect.
* Remove deprecated integral comparison interfaces: `bson_in_range_*` and `bson_cmp_*`.
* Remove deprecated atomic and threading interfaces: `bson_atomic_*` and `bson_thrd_yield`.
* The deprecated `ENABLE_EXTRA_ALIGNMENT` CMake option is removed.
* `bson_t` and `bson_iter_t` are now aligned to the size of a pointer instead of `128`.
* `bson_error_t`, `bson_value_t`, and `bson_visitor_t` are now aligned to the size of a pointer instead of `8`.
* `BSON_ALIGNED_BEGIN` and `BSON_ALIGNED_END` now unconditionally apply their requested alignment.


libbson 1.30.2
==============
Expand Down
3 changes: 1 addition & 2 deletions src/libbson/doc/bson_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ Synopsis
#define BSON_APPEND_VALUE(b, key, val) \
bson_append_value (b, key, (int) strlen (key), (val))

BSON_ALIGNED_BEGIN (128)
typedef struct {
uint32_t flags; /* Internal flags for the bson_t. */
uint32_t len; /* Length of BSON data. */
uint8_t padding[120]; /* Padding for stack allocation. */
} bson_t BSON_ALIGNED_END (128);
} bson_t;

Description
-----------
Expand Down
8 changes: 0 additions & 8 deletions src/libbson/src/bson/bson-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@
#endif


/*
* Define to 1 if you want extra aligned types in libbson
*/
#define BSON_EXTRA_ALIGN @BSON_EXTRA_ALIGN@
#if BSON_EXTRA_ALIGN != 1
# undef BSON_EXTRA_ALIGN
#endif


/*
* Define to 1 if you have rand_r available on your platform.
Expand Down
10 changes: 0 additions & 10 deletions src/libbson/src/bson/bson-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,13 @@
#define BSON_ALIGN_OF_PTR (BSON_ALIGNOF (void *))
#endif

#ifdef BSON_EXTRA_ALIGN
#if defined(_MSC_VER)
#define BSON_ALIGNED_BEGIN(_N) __declspec (align (_N))
#define BSON_ALIGNED_END(_N)
#else
#define BSON_ALIGNED_BEGIN(_N)
#define BSON_ALIGNED_END(_N) __attribute__ ((aligned (_N)))
#endif
#else
#if defined(_MSC_VER)
#define BSON_ALIGNED_BEGIN(_N) __declspec (align (BSON_ALIGN_OF_PTR))
#define BSON_ALIGNED_END(_N)
#else
#define BSON_ALIGNED_BEGIN(_N)
#define BSON_ALIGNED_END(_N) __attribute__ ((aligned ((_N) > BSON_ALIGN_OF_PTR ? BSON_ALIGN_OF_PTR : (_N))))
#endif
#endif


#define bson_str_empty(s) (!s[0])
Expand Down
13 changes: 8 additions & 5 deletions src/libbson/src/bson/bson-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ typedef enum {
#define BSON_INLINE_DATA_SIZE 120


BSON_ALIGNED_BEGIN (128)
BSON_ALIGNED_BEGIN (BSON_ALIGN_OF_PTR)
typedef struct {
bson_flags_t flags;
uint32_t len;
uint8_t data[BSON_INLINE_DATA_SIZE];
} bson_impl_inline_t BSON_ALIGNED_END (128);
} bson_impl_inline_t BSON_ALIGNED_END (BSON_ALIGN_OF_PTR);


BSON_STATIC_ASSERT2 (impl_inline_t, sizeof (bson_impl_inline_t) == 128);


BSON_ALIGNED_BEGIN (128)
typedef struct {
bson_flags_t flags; /* flags describing the bson_t */
/* len is part of the public bson_t declaration. It is not
Expand All @@ -71,11 +69,16 @@ typedef struct {
size_t alloclen; /* length of buffer that we own. */
bson_realloc_func realloc; /* our realloc implementation */
void *realloc_func_ctx; /* context for our realloc func */
} bson_impl_alloc_t BSON_ALIGNED_END (128);
} bson_impl_alloc_t;


BSON_STATIC_ASSERT2 (impl_alloc_t, sizeof (bson_impl_alloc_t) <= 128);

// Ensure both `bson_t` implementations have the same alignment requirement:
BSON_STATIC_ASSERT2 (impls_match_alignment, BSON_ALIGNOF (bson_impl_inline_t) == BSON_ALIGNOF (bson_impl_alloc_t));
// Ensure `bson_t` has same alignment requirement as implementations:
BSON_STATIC_ASSERT2 (impls_match_alignment, BSON_ALIGNOF (bson_t) == BSON_ALIGNOF (bson_impl_alloc_t));


BSON_END_DECLS

Expand Down
Loading