Skip to content

[libunwind] Add Unwind-wasm.c to CMakeLists.txt #20371

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

Closed
wants to merge 2 commits into from

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Oct 2, 2023

Even though we don't use CMakeLists.txt, Unwind-wasm.c needs to be included in the file to be a part of libunwind. Reflecting changes of llvm/llvm-project#67770.

The order of headers and inserted newlines are to satisfy LLVM CI and clang-format.

  • stdbool.h should be before config.h because otherwise bool is not defined. But there should be a newline between them because otherwise clang-format will reorder them alphabetically
  • We need at least one header outside of #ifdef __USING_WASM_EXCEPTIONS__ because LLVM CI complains there should be at least one declaration within a compilation unit, and stdbool.h doesn't have any, so we need another header outside
  • threads.h doesn't exist in other platforms. (It's in musl) So it needs to be in #ifdef __USING_WASM_EXCEPTIONS__

Even though we don't use `CMakeLists.txt`, `Unwind-wasm.c` needs to be
included in the file to be a part of libunwind. Reflecting changes of
llvm/llvm-project#67770.

The order of headers and inserted newlines are to satisfy LLVM CI and
clang-format.
- `stdbool.h` should be before `config.h` because otherwise `bool` is
  not defined. But there should be a newline between them because
  otherwise clang-format will reorder them alphabetically
- We need at least one header outside of `#ifdef
  __USING_WASM_EXCEPTIONS__` because LLVM CI complains there should be
  at least one declaration within a compilation unit, and `stdbool.h`
  doesn't have any, so we need another header outside
- `threads.h` doesn't exist in other platforms. (It's in musl) So it
  needs to be in `#ifdef __USING_WASM_EXCEPTIONS__`
@aheejin aheejin requested a review from sbc100 October 2, 2023 20:49
@sbc100
Copy link
Collaborator

sbc100 commented Oct 2, 2023

Is there any point in landing this downstream in emscripten? Should we not just wait for the llvm change to make its way into a release?

Doing this way will cause our patch size against 16.0.6 to increase, no?

@aheejin
Copy link
Member Author

aheejin commented Oct 2, 2023

Yeah it might not be necessary... I just wanted to sync them because I don't expect changes to libunwind for a while. Not sure what you mean by increasing the patch size.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 2, 2023

Yeah it might not be necessary... I just wanted to sync them because I don't expect changes to libunwind for a while. Not sure what you mean by increasing the patch size.

At any given time emscripten carries a certain set of patches from the upstream llvm repo. For example, right now that is the difference between the 16.0.6 tag and our branch in our llvm fork (emscripten-libs-16).

Every time we change emscripten's copy of these core libraries it increases our patch size. Even if that change is cherry-picked from llvm main (as this one is). One way so see that the patch size is increased would be to run system/libs/push_to_llvm.py. If you landed this PR and then ran that script this change would be pushed to our fork.

Cherry-picking from main might be OK, if there was good reason to, but I'm not sure there is in this case.

@aheejin
Copy link
Member Author

aheejin commented Oct 3, 2023

I guess I see what you mean by increasing the patch size, but does the patch size matter, or is there a reason we should minimize it?

@sbc100
Copy link
Collaborator

sbc100 commented Oct 3, 2023

I guess I see what you mean by increasing the patch size, but does the patch size matter, or is there a reason we should minimize it?

In general, we want to keep our deviations from upstream as small as possible yes. This makes all out processes like merging and rebasing easier.

In this case that patch happens to be one that is already landed upsteam on main.. so its unlikely to cause trouble. But I also don't see any reason to cherry-pick it early.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 3, 2023

I guess I see what you mean by increasing the patch size, but does the patch size matter, or is there a reason we should minimize it?

In general, we want to keep our deviations from upstream as small as possible yes. This makes all out processes like merging and rebasing easier.

In this case that patch happens to be one that is already landed upsteam on main.. so its unlikely to cause trouble. But I also don't see any reason to cherry-pick it early.

Perhaps there is some reason that I am missing? Why would we want this file to be on llvm-main and the other files to be on llvm-16?

@aheejin
Copy link
Member Author

aheejin commented Oct 3, 2023

I guess I see what you mean by increasing the patch size, but does the patch size matter, or is there a reason we should minimize it?

In general, we want to keep our deviations from upstream as small as possible yes. This makes all out processes like merging and rebasing easier.
In this case that patch happens to be one that is already landed upsteam on main.. so its unlikely to cause trouble. But I also don't see any reason to cherry-pick it early.

Perhaps there is some reason that I am missing? Why would we want this file to be on llvm-main and the other files to be on llvm-16?

No I wasn't thinking in terms of llvm-main vs. llvm-16. Because I recently upstreamed our libc++abi / libunwind changes to the llvm repo, but this small change was missing, I just wanted to sync them, that's all. As you pointed out, this change doesn't affect us one way or another so it's not urgent or anything. I was just wondering why we needed to make the patch size small.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 3, 2023

I guess I see what you mean by increasing the patch size, but does the patch size matter, or is there a reason we should minimize it?

In general, we want to keep our deviations from upstream as small as possible yes. This makes all out processes like merging and rebasing easier.
In this case that patch happens to be one that is already landed upsteam on main.. so its unlikely to cause trouble. But I also don't see any reason to cherry-pick it early.

Perhaps there is some reason that I am missing? Why would we want this file to be on llvm-main and the other files to be on llvm-16?

No I wasn't thinking in terms of llvm-main vs. llvm-16. Because I recently upstreamed our libc++abi / libunwind changes to the llvm repo, but this small change was missing, I just wanted to sync them, that's all. As you pointed out, this change doesn't affect us one way or another so it's not urgent or anything. I was just wondering why we needed to make the patch size small.

Because we sync to llvm only on major release I think its OK to be out-of-sync with main at any given time... unless the changes from main are some kind of critical bug fix.

Of course, if you disagree and feel that these particular files should llvm-main we can land this.

@aheejin
Copy link
Member Author

aheejin commented Oct 3, 2023

It's not urgent; I will close it then.

@aheejin aheejin closed this Oct 3, 2023
@aheejin aheejin deleted the unwind_cmake branch October 3, 2023 01:31
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