tracy icon indicating copy to clipboard operation
tracy copied to clipboard

GCC and Clang compatible on Windows

Open FilipNur opened this issue 8 months ago • 12 comments

Made simple modifications so that project can be compiled wiith Clang and GCC on Windows

FilipNur avatar May 31 '25 23:05 FilipNur

@wolfpld, I finished changing source so it compiles with gcc and clang on Windows. I tested it on both compilers, test program that uses Tracy, and Tracy profiler itself compile successfully. The initial problem with safe memcpy is solved using pipes for data transfer similar to linux implementation. I wasn't able to find fix for too many sections that I mentioned before and just disabled CMAKE_INTERPROCEDURAL_OPTIMIZATION when compiling with gcc.

FilipNur avatar Jun 08 '25 16:06 FilipNur

@wolfpld Fixed things you pointed out and some other minor things.

FilipNur avatar Jun 08 '25 21:06 FilipNur

@FilipNur Your PR rewrites the entire TracyProfiler.cpp file. Can you fix that?

mcourteaux avatar Jun 19 '25 14:06 mcourteaux

@mcourteaux I know and I don't know why. I will push changes when I resolve this issue.

FilipNur avatar Jun 20 '25 13:06 FilipNur

As I can't assess what your PR does due to this issue, make sure it's still relevant after my last PR was merged.

mcourteaux avatar Jun 20 '25 13:06 mcourteaux

@mcourteaux I see that your pull request is also about mingw compatibility so my pull request might be not needed, as I was trying to achieve something similar. But I have one question: in your changes to TracyProfiler.cpp you did

#ifdef _WIN32
+ #  ifdef _MSC_VER
      __try
      {
          memcpy( buf, data, size );
      {
          success = false;
      }
+ #  else
+     memcpy( buf, data, size );
+ #  endif
    #else
    ...

Where the memcpy, that is executed if _MSC_VER is not defined, is not protected against potential segfault. I am just curious why was it merged, because when I proposed just bare memcpy in first request, @wolfpld sent me to #889, whetre issue says about ensuring safe memcpy.

FilipNur avatar Jun 22 '25 17:06 FilipNur

It's an incremental step.

wolfpld avatar Jun 22 '25 17:06 wolfpld

Fixed line endings in public/client/TracyProfiler.cpp and rebased project to latest master branch.

FilipNur avatar Jun 22 '25 19:06 FilipNur

@FilipNur You seem to have made a PR that includes a bunch of commits that are already on master. If you struggle with figuring out how to correct things, a very manual trick I have used once or twice, that resolves this very easily, is to generate a git diff --patch master gcc_and_clang_compatible patch file from your changes between master and your work. The patch file will contain all changes between those to commits, regardless of the history that happened between them. Then you make a new branch, forked from master, (let's say it's called my-temp-branch) and you apply the patch file there. Afterwards you can inspect if everything looks fine, and your new branch seems like the changes you want to commit. Make a commit on that new branch. Now go back to your gcc_and_clang_compatible branch, and git reset --hard my-temp-branch. Git will now ignore your messy git commit history, and have one commit on your gcc_and_clang_compatible branch which is just the patch file you applied.

If you mess up any of the steps, there is always git reflog to find your work back.

mcourteaux avatar Jun 23 '25 08:06 mcourteaux

Thanks @mcourteaux, I cleaned up the code using your method.

FilipNur avatar Jun 25 '25 13:06 FilipNur

@wolfpld Could you check it?

FilipNur avatar Jul 06 '25 11:07 FilipNur

You are still changing way too much code for no reason, especially in external libraries, and there are comments you have not addressed properly. What's there to check?

wolfpld avatar Jul 06 '25 12:07 wolfpld