Skip to content

Fix alignment mismatch warning#754

Open
jschwe wants to merge 1 commit into
servo:mainfrom
jschwe:alignment_warning
Open

Fix alignment mismatch warning#754
jschwe wants to merge 1 commit into
servo:mainfrom
jschwe:alignment_warning

Conversation

@jschwe

@jschwe jschwe commented Jun 11, 2026

Copy link
Copy Markdown
Member

During the ESR 128 upgrade this patch was added to fix an issue with the generated bindings.
The problem doesn't seem to exist anymore and removing the patch seems to work just fine and fixes a clang warning about mismatching alignment.

warning: mozjs_sys@140.11.0-0: /Users/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ef4f07daefa91c0c/out/build/dist/include/js/ColumnNumber.h:325:12: warning: passing 1-byte aligned argument to 4-byte aligned parameter 'this' of 'MaybeLimitedColumnNumber' may result in an unaligned pointer access [-Walign-mismatch]
warning: mozjs_sys@140.11.0-0:   325 |     return ColumnNumberOneOrigin(value + 1);
warning: mozjs_sys@140.11.0-0:       |            ^
warning: mozjs_sys@140.11.0-0: ./src/jsapi.cpp:321:7: warning: passing 1-byte aligned argument to 4-byte aligned parameter 'this' of 'MaybeLimitedColumnNumber' may result in an unaligned pointer access [-Walign-mismatch]
warning: mozjs_sys@140.11.0-0:   321 |       JS::ColumnNumberOneOrigin(columnNumber), report, message,
warning: mozjs_sys@140.11.0-0:       |       ^

Testing: Should be covered by a full servo try run
Servo PR: pending

During the ESR 128 upgrade this patch was added to fix an issue
with the generated bindings.
The problem doesn't seem to exist anymore and removing the patch
seems to work just fine and fixes a clang warning about mismatching
alignment.

```
warning: mozjs_sys@140.11.0-0: /Users/runner/work/mozjs/mozjs/target/debug/build/mozjs_sys-ef4f07daefa91c0c/out/build/dist/include/js/ColumnNumber.h:325:12: warning: passing 1-byte aligned argument to 4-byte aligned parameter 'this' of 'MaybeLimitedColumnNumber' may result in an unaligned pointer access [-Walign-mismatch]
warning: mozjs_sys@140.11.0-0:   325 |     return ColumnNumberOneOrigin(value + 1);
warning: mozjs_sys@140.11.0-0:       |            ^
warning: mozjs_sys@140.11.0-0: ./src/jsapi.cpp:321:7: warning: passing 1-byte aligned argument to 4-byte aligned parameter 'this' of 'MaybeLimitedColumnNumber' may result in an unaligned pointer access [-Walign-mismatch]
warning: mozjs_sys@140.11.0-0:   321 |       JS::ColumnNumberOneOrigin(columnNumber), report, message,
warning: mozjs_sys@140.11.0-0:       |       ^
```

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
@jschwe jschwe force-pushed the alignment_warning branch from 131b61f to 1999704 Compare June 11, 2026 11:03
@jschwe jschwe marked this pull request as ready for review June 11, 2026 11:03
@jdm

jdm commented Jun 11, 2026

Copy link
Copy Markdown
Member

Mmm, still appears to be necessary on some platforms:

error[E0080]: evaluation of constant value failed
    --> /home/runner/work/mozjs/mozjs/target/aarch64-linux-android/debug/build/mozjs_sys-1917c19ce6f88f02/out/build/jsapi.rs:8766:13
     |
8766 | /             ["Offset of field: ReadOnlyCompileOptions::lineno"]
8767 | |                 [::std::mem::offset_of!(ReadOnlyCompileOptions, lineno) - 58usize];
     | |__________________________________________________________________________________^ index out of bounds: the length is 1 but the index is 2

``|

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.

2 participants