这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@winspool
Copy link
Contributor

@winspool winspool commented Nov 30, 2024

Since the affectes compiler does not support SSE/AVX,
a bigger alignment is not needed.

Summary by CodeRabbit

  • New Features

    • Introduced a fallback definition for the ALIGNED_ macro to enhance compatibility with various compilers.
  • Bug Fixes

    • Improved macro flexibility for future compiler-specific implementations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 30, 2024

Walkthrough

The changes involve the zbuild.h header file, where a fallback definition for the ALIGNED_ macro has been added. This modification ensures that if no specific compiler support is detected, a placeholder definition is provided. The rest of the file remains unchanged, maintaining existing functionality.

Changes

File Change Summary
zbuild.h Added fallback definition for ALIGNED_ macro.

Suggested reviewers

  • Dead2

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
zbuild.h (1)

204-204: Enhance the TODO comment with more context

The TODO comment could be more descriptive to help future maintainers understand when and why they might need to define ALIGNED_ for their compiler.

Consider updating it to:

-/* TODO: Define ALIGNED_ for your compiler */
+/* TODO: Define ALIGNED_(x) for your compiler if it requires specific alignment directives for SSE/AVX optimizations */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5456966 and 7b625d2.

📒 Files selected for processing (1)
  • zbuild.h (1 hunks)
🔇 Additional comments (1)
zbuild.h (1)

203-205: LGTM! The fallback implementation is safe and appropriate

The empty fallback for ALIGNED_ is correct when the compiler doesn't support or require specific alignment directives. This is particularly suitable for compilers without SSE/AVX support where strict alignment isn't necessary.

Let's verify the macro usage to ensure the fallback is safe:

@Dead2
Copy link
Member

Dead2 commented Dec 3, 2024

@winspool Just wondering, what compiler is hitting this?

@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 32.12%. Comparing base (5456966) to head (7b625d2).
Report is 7 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1820      +/-   ##
===========================================
- Coverage    32.19%   32.12%   -0.07%     
===========================================
  Files           67       67              
  Lines         5752     5752              
  Branches      1237     1237              
===========================================
- Hits          1852     1848       -4     
  Misses        3644     3644              
- Partials       256      260       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@winspool
Copy link
Contributor Author

winspool commented Dec 3, 2024

@winspool Just wondering, what compiler is hitting this?

OpenWatcom v2 on linux

TODO:

  • a patch related to cpuid()
    (Fallback: returning 0 in the variables with the registernames)

  • a patch related to xgetbv
    (Fallback: returning 0 should be ok)

  • a patch relatet to zng_alloc
    OW does not support posix_memalign() and alligned_alloc() yet
    Using the normal malloc() should work,
    as the intinsics are not supported
    and the higher alignment is probably not required.

Yes, all together the result is a lot slower as possible,
but at a first step, it has to work.

@winspool
Copy link
Contributor Author

winspool commented Dec 3, 2024

@winspool Just wondering, what compiler is hitting this?

My _build script is here:

https://github.com/winspool/_build.git

I build with autotools, which results in configure --static --32
and for OpenWatcom, i have to overwrite AR and ARFLAGS:

HOST=" "  AR="wlib"  ARFLAGS="-n"  _build  --static  --32

Btw, cross-compiling on linux for _WIN32 fails,
but cross-compiling ( including make test ) works here
for DOS with the causeway extender.
(works also with the dos4gw extender)

@winspool
Copy link
Contributor Author

winspool commented Dec 3, 2024

Proposed additional portability-patches to allow OpenWatcom and tcc to compile zlib-ng:

Use a fallback for cpuid related functions:
0003-portability-Add-a-fallback-for-cpuid-related-functio.txt

Use a fallback for memalign:
0002-portability-Check-for-memalign-when-available.-Other.txt


When patch 0002 is an acceptable style, i can update configure and CMakeList.txt
in a similar style for the cpuid related functions/includes.

This will also fix cross compiling for windows (tested with i386-win32-tcc and x86_64-win32-tcc)

@winspool
Copy link
Contributor Author

winspool commented Dec 3, 2024

@winspool Just wondering, what compiler is hitting this?

Forgot to mention, that tcc is also affected

@mtl1979
Copy link
Collaborator

mtl1979 commented Dec 4, 2024

Generally I'm not against adding support for new compilers, but it seems these compilers target "configurations" that are not highest priority for zlib-ng as most of the optimisations get disabled.

@winspool
Copy link
Contributor Author

winspool commented Dec 5, 2024

Generally I'm not against adding support for new compilers,

Great.
The improved speed look interesting,
but requiring to use one of the 3 mainstream compiler
for the speedup is not needed.

I usually use autotools, but the provided configure script
is simple enough to be easily extended.
And for cmake, i test with gcc and clanng.
I have no MSVC installed, and hope, that zlib-ng is able to extended and test the related parts it in a similar way.

but it seems these compilers target "configurations"
that are not highest priority for zlib-ng as most of the optimisations get disabled.

Get it runing without optimization is only the first step.
I hope to get the optimized code running without depending on a specific toolchain, when possible (thanks to the intrinsics).

The C++ tests won't work, when using tcc (Tiny C Compiler: only C)
or when using OpenWatcom (Missing Many C++11 features),
but the simple C test work on all compiler, which i have tested.

@winspool
Copy link
Contributor Author

winspool commented Dec 5, 2024

Please give me some infos, what i can do,
to get my suggested portability changes in the main tree?

Is an update to this simple PR needed?
Are the other attached proposed changes OK?
How many portability changes in one PR is acceptable?
What else?

@winspool
Copy link
Contributor Author

winspool commented Dec 5, 2024

I didn't looked at the CodeCov integration yet,
but i have additional changes to test the different memory allocation strategies locally.

@mtl1979
Copy link
Collaborator

mtl1979 commented Dec 5, 2024

Please give me some infos, what i can do, to get my suggested portability changes in the main tree?

Is an update to this simple PR needed? Are the other attached proposed changes OK? How many portability changes in one PR is acceptable? What else?

Adding support for one compiler per pull request is usually good idea as it makes reviewing the necessary changes easier... If two or more compilers benefit for overlapping changes, then adding the overlapping part first as own commit in PR makes it clear what changes overlap and what are specific to each compiler. If just the overlapping part doesn't result in successful build, then combine it with enough code for one compiler configuration that results in successful build (smaller initial commit is better).

We allow incremental patches that span multiple pull requests, but generally single PR shouldn't break the build for any configuration, or revert changes in previous PR in same patch series. Reverting older changes is acceptable as long as the older change was clearly bad or it is no longer needed due to other changes committed in between.

As far as I know latest stable version of Watcom compiler is quite old (it was released the same day my older girl was born), but I haven't yet checked what newer features are planned for the current beta version or when the feature freeze is for that branch.

I know almost nothing about Tiny C Compiler, so can't comment on that yet...

@mtl1979
Copy link
Collaborator

mtl1979 commented Dec 5, 2024

Patch 3 doesn't look quite right, but the first two have nothing seriously bad that I can notice... Clang as far as I know defines __GNUC__ as it reuses parts of GNU toolchain for binary compatibility. This is why to test for GCC, it is necessary to test that __GNUC__ is defined, but the preprocessor defines for other forked compilers are not defined, including for example Clang and Intel compilers.

@Dead2
Copy link
Member

Dead2 commented Dec 6, 2024

In general, we don't support this compiler, but I am not against merging patches like this one that really has no downside.
In this case, I think we can actually call this a bug, the macro should have had a fallback.

@Dead2 Dead2 changed the title zbuild: Provide a fallback for "ALIGNED_(x)" for other compiler Add a fallback to ALIGNED_ macro for other compilers Dec 6, 2024
@Dead2 Dead2 added the Build Env label Dec 6, 2024
@winspool
Copy link
Contributor Author

winspool commented Dec 6, 2024

In general, we don't support this compiler, but I am not against merging patches like this one that really has no downside.
In this case, I think we can actually call this a bug, the macro should have had a fallback.

Thanks.
What's next for this pull requests?

@KungFuJesus
Copy link
Contributor

Curiously this macro was causing problems for me with CMake, GCC, and PowerPC. I never got to the bottom of it, though. We actually do need alignment for VMX, otherwise you get the fun side effect of a load happening at the next alignment boundary, silently.

@Dead2
Copy link
Member

Dead2 commented Dec 7, 2024

Curiously this macro was causing problems for me with CMake, GCC, and PowerPC. I never got to the bottom of it, though. We actually do need alignment for VMX, otherwise you get the fun side effect of a load happening at the next alignment boundary, silently.

@KungFuJesus I am a little uncertain about this comment, so I hope you can clarify; Is this a Pro/Con on this PR, or a suggestion for later, or just a comment?

@KungFuJesus
Copy link
Contributor

Curiously this macro was causing problems for me with CMake, GCC, and PowerPC. I never got to the bottom of it, though. We actually do need alignment for VMX, otherwise you get the fun side effect of a load happening at the next alignment boundary, silently.

@KungFuJesus I am a little uncertain about this comment, so I hope you can clarify; Is this a Pro/Con on this PR, or a suggestion for later, or just a comment?

Mostly just a comment. The issue likes somewhere in CMake, I think. There's a pending PR for PPC that suddenly breaks the machinery around how we specify this macro: #1690
It's not entirely tangential, it might make things silently fail if that other PR is merged. I really need to get to the bottom of that.

@Dead2
Copy link
Member

Dead2 commented Dec 8, 2024

Mostly just a comment. The issue likes somewhere in CMake, I think. There's a pending PR for PPC that suddenly breaks the machinery around how we specify this macro: #1690 It's not entirely tangential, it might make things silently fail if that other PR is merged. I really need to get to the bottom of that.

Ah #1690, now I get it 👍

@Dead2 Dead2 merged commit a4e7c34 into zlib-ng:develop Dec 8, 2024
144 of 150 checks passed
@winspool winspool deleted the portability branch December 22, 2024 02:23
@Dead2 Dead2 mentioned this pull request Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants