Skip to content
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

Fix compiling due to typedefs varying across platforms #1729

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

C0rn3j
Copy link
Contributor

@C0rn3j C0rn3j commented Dec 10, 2024

Fix the var ordering.

#1724 breaks it and CI does not catch it, as it is using clang a compiler old enough to be complacent.

Note that I do not usually do C++ so the fix may be wrong, even though it works for me.

typedef struct
  {
    void *ss_sp;
    int ss_flags;
    size_t ss_size;
  } stack_t;

Fixes error: designator order for field ‘stack_t::ss_flags’ does not match declaration order in ‘const stack_t’

Do squash the extra commit when merging please

@squidbus
Copy link
Collaborator

Two things:

  • AFAIK this is a GCC thing, not a "modern C++ compiler" thing.
  • The order of fields used currently is how they appear on my system, not how you have set them.

@C0rn3j
Copy link
Contributor Author

C0rn3j commented Dec 10, 2024

The order of fields used currently is how they appear on my system, not how you have set them.

The typedef is taken from signal.h which includes stack_t.h:
image

EDIT: Even the docs have a mistmatching order with my system 2.40 glibc????

https://www.gnu.org/software/libc/manual/html_node/Signal-Stack.html

@squidbus
Copy link
Collaborator

stack_t

@C0rn3j
Copy link
Contributor Author

C0rn3j commented Dec 10, 2024

That's fun... does this simple declaration need to have a platform dependent ifdef then, or is there a more reasonable way to solve this?

AFAIK this is a GCC thing, not a "modern C++ compiler" thing.

I was under the impression that this here runs the same thing as my system - I suppose gcc - just an old version of it?

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc)

@raphaelthegreat
Copy link
Collaborator

Would probably change it to not use designated initializers to avoid platform ifdef

@squidbus
Copy link
Collaborator

I was under the impression that this here runs the same thing as my system - I suppose gcc - just an old version of it?

https://github.com/shadps4-emu/shadPS4/blob/main/.github/workflows/build.yml#L370-L371

We configure the build to use clang here.

@C0rn3j C0rn3j changed the title Fix compiling on modern C++ compilers Fix compiling with gcc Dec 10, 2024
@C0rn3j
Copy link
Contributor Author

C0rn3j commented Dec 10, 2024

image

I am beyond confused as to how my system version mismatches the upstream git version last touched in 2016 AND documentation also agrees with this git version and not what's installed on my system...

Even the commit that Arch supposedly installs has flags last.

https://sourceware.org/git/?p=glibc.git;a=blob;f=bits/types/stack_t.h;h=21610f1d3d6ad004f10642fc5d8556688d961426;hb=aa533d58ff12e27771d9c960a727d74992a3f2a3

Looks like I will be taking this to my distribution first.

EDIT: Nope, glibc bs.

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/types/stack_t.h;h=497e42b0ff6d19cdd287478d12ac4916d7889d89;hb=0bcec5321f7d31c31e4fd601d4e0922862d87b14

https://sourceware.org/git/?p=glibc.git;a=blob;f=bits/types/stack_t.h;h=3cf0a4019a044f9235477606c45eb2642d0307a7;hb=0bcec5321f7d31c31e4fd601d4e0922862d87b14

EDIT2: And this VARIES between different Linux platforms on top of that - https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=0bcec5321f7d31c31e4fd601d4e0922862d87b14#patch2
bits/types/stack_t.h has three variants different in the order of the structure elements (generic = MIPS Linux, and other Linux) Well that was a waste of time, time to figure out how to do it without designated initializers, no clue why you'd have the names if you'd then ignore them and use the order anyway, but now I am just ranting about C++ :)

@C0rn3j
Copy link
Contributor Author

C0rn3j commented Dec 10, 2024

That works, builds, passes CI and it's not a designated initializer, but not tagged constant either anymore.

Is this fine as is?

@C0rn3j C0rn3j changed the title Fix compiling with gcc Fix compiling due to typedefs varying across platforms Dec 10, 2024
@squidbus
Copy link
Collaborator

This looks fine to me yes.

@raphaelthegreat raphaelthegreat merged commit b8a443c into shadps4-emu:main Dec 10, 2024
10 checks passed
@C0rn3j C0rn3j deleted the C0rn3j-patch-1 branch December 10, 2024 20:24
diegolix29 pushed a commit to diegolix29/shadPS4 that referenced this pull request Dec 11, 2024
)

* Fix compiling on modern C++ compilers

shadps4-emu@cd9fc5d broke it

* Fix order

* Test

* Test putting flags in old order

* Remove designated initializer
Xcedf pushed a commit to Xcedf/shadPS4 that referenced this pull request Dec 28, 2024
)

* Fix compiling on modern C++ compilers

shadps4-emu@cd9fc5d broke it

* Fix order

* Test

* Test putting flags in old order

* Remove designated initializer
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.

3 participants