Skip to content

[GEN][ZH] Add compilation for Linux #522

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 24 commits into from

Conversation

feliwir
Copy link

@feliwir feliwir commented Mar 27, 2025

Based on #479
Targets fixed:

Generals:

  • g_compress
  • g_wwvegas
    • g_wwlib
    • g_wwdebug
    • g_wwmath
    • g_wwsaveload
    • g_wwutil
    • ....

Zero Hour:

  • z_compress
  • z_wwvegas
    • z_wwlib
    • z_wwdebug
    • z_wwmath
    • z_wwsaveload
    • z_wwutil
    • ...
  • ...

@xezon xezon marked this pull request as ready for review March 27, 2025 13:14
@xezon xezon marked this pull request as draft March 27, 2025 13:14
@feliwir feliwir force-pushed the SH/linux-cli-fixes branch 16 times, most recently from 0526867 to 2b15bb6 Compare March 28, 2025 13:24
@DevGeniusCode DevGeniusCode added the Build Anything related to building, compiling label Mar 28, 2025
@feliwir feliwir force-pushed the SH/linux-cli-fixes branch from e33d6eb to f668cf3 Compare March 29, 2025 13:37
@feliwir feliwir changed the title Add compilation for CLI tools on Linux Add compilation for Linux Mar 29, 2025
@feliwir feliwir force-pushed the SH/linux-cli-fixes branch 5 times, most recently from 6eae27b to c588356 Compare March 30, 2025 20:47
@zzambers
Copy link

Is there a reason, why debug directory was renamed to Debug?

Comment on lines 524 to +527
float det;
#ifdef _WIN32
D3DXMatrixInverse((D3DXMATRIX *)&mat4Inv, &det, (D3DXMATRIX*)&mat4);
#endif

Choose a reason for hiding this comment

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

I think some alternative implementation should be provided or some kind runtime error should be produced...

Copy link
Author

Choose a reason for hiding this comment

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

I'll use GLM here (as we do on our fork). However first i want to integrate VCPKG (possibly a separate PR). For linux to work we need a few external libraries and VCPKG makes that a lot easier.

Copy link

Choose a reason for hiding this comment

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

Not sure if this specific line is that, but what happens in the code at many places is a row major to column major matrix conversion or vice versa. We polished this in Thyme and it needs to be done in this code as well. This needs to be done in a separate change because it is bigger change. Here is the reference:

TheAssemblyArmada/Thyme@2114738

Comment from that change:

// When converting Matrix4 to D3DMATRIX or vice versa always use conversion function below.
 
// Reason being, D3DMATRIX is row major matrix, and Matrix4 is column major matrix.
 
// Thus copying from one to another will always require a transpose (or invert).

I have opened task with #552

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

@zzambers zzambers Mar 31, 2025

Choose a reason for hiding this comment

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

@feliwir I have no doubts that you plan to implement it later. :) My point was more about approach to unimplemented code. I think there should be some unified way how to handle this, right from the start, otherwise there is a danger of silently broken code, if it gets forgotten. Also It would be nice to be able to search for unimplemented code. I have created issue, where I formulated this in more detail.

Comment on lines 230 to 241
void Lock_Mem_Log_Mutex(void)
{
#ifdef _WIN32
void * mutex = Get_Mem_Log_Mutex();
#ifdef DEBUG_CRASHING
int res =
#endif
WaitForSingleObject(mutex,INFINITE);
WWASSERT(res==WAIT_OBJECT_0);
_MemLogLockCounter++;
#endif
}

Choose a reason for hiding this comment

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

I think some alternative implementation should be provided or some kind runtime error should be produced...

Copy link
Author

Choose a reason for hiding this comment

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

We can use std::mutex here, however i'm not sure if the memlogging is used much? When searching for function invocations i only get a few, which don't need any locking mechanism (only ww3d.cpp)

Choose a reason for hiding this comment

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

Why not just replace this version of wwmemlog with the version from ZH which seemingly is more linux friendly?

Copy link
Author

Choose a reason for hiding this comment

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

I didn't look at that one yet, but when we do dedup first, this probably will resolve itself

@feliwir
Copy link
Author

feliwir commented Mar 31, 2025

Is there a reason, why debug directory was renamed to Debug?

Yes, otherwise it comflicts with GCC standardlibrary, which includes a header named debug/debug.h

@feliwir feliwir force-pushed the SH/linux-cli-fixes branch from 82ca1d3 to 60d9e2e Compare March 31, 2025 05:47
@feliwir feliwir changed the title Add compilation for Linux [GEN][ZH] Add compilation for Linux Mar 31, 2025
@feliwir feliwir force-pushed the SH/linux-cli-fixes branch from 60d9e2e to a53a8f4 Compare March 31, 2025 07:34
feliwir and others added 12 commits March 31, 2025 11:23
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
 Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
@feliwir feliwir force-pushed the SH/linux-cli-fixes branch from a53a8f4 to 820c397 Compare March 31, 2025 09:23
@xezon xezon added this to the Code foundation build up milestone Mar 31, 2025
@zzambers
Copy link

zzambers commented Mar 31, 2025

Note, that this is related to my PR to make code compile with MinGW toolchain as GCC compiler is used in both cases. I think it would make most sense for this to go on top of MinGW support, because:

  • MinGW uses windows-compatible headers, so are changes are mostly fixes for GCC. I have changes for ZH (game + internal libraries) basically done (most changes are in engine). Now I just want to redo commits (combining some, for easier review). Then I plan to do backport to GEN.
  • Linux port on the other hand needs fixes for GCC + replacements for windows-specific stuff, so when finished is mostly superset of MinGW effort. So I think it would make sense to (re)base it on MinGW work.

btw. build fixes for GCC also slightly overlap with VC warning fixes (+ need asm replacements).

@feliwir
Copy link
Author

feliwir commented Apr 4, 2025

Will be redone after commonizing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Anything related to building, compiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants