Skip to content

Commit

Permalink
Upgrade tracy to v0.11.1
Browse files Browse the repository at this point in the history
Tracy moved from Make to CMake in v0.11, so the Setup.hs machinery has
to be updated. Fortunately, the result is simpler, but we do (of course)
gain a dependency on CMake.
  • Loading branch information
tomsmeding committed Nov 29, 2024
1 parent 8f5e853 commit 0b9467f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ jobs:
echo CABAL_FLAGS=--enable-tests --test-show-details=direct --flags=nofib >> $GITHUB_ENV
else
if [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
sudo apt-get -y install pkg-config libcapstone-dev libfreetype-dev libglfw3-dev libgtk-3-dev libtbb-dev
sudo apt-get -y install cmake pkg-config libfreetype-dev libglfw3-dev libgtk-3-dev libtbb-dev
elif [ ${{ matrix.os }} == 'macOS-latest' ]; then
brew install pkg-config capstone freetype glfw
brew install cmake pkg-config freetype glfw
fi
echo CABAL_FLAGS=--enable-tests --test-show-details=direct --flags=nofib --flags=debug --ghc-options=\"-optc=-DTRACY_TIMER_FALLBACK\" --ghc-options=\"-optcxx=-DTRACY_TIMER_FALLBACK\" >> $GITHUB_ENV
fi
Expand Down
6 changes: 1 addition & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This is on a fork only for the following commit:
# https://github.com/wolfpld/tracy/commit/1a971d867d6fa5bf6dc57d705dcbbc6020031e7a
# which fixes a dumb compile error.
# When tracy publishes something > v0.10, please upgrade to that instead.
[submodule "cbits/tracy"]
path = cbits/tracy
url = https://github.com/tomsmeding/tracy.git
url = https://github.com/wolfpld/tracy.git
59 changes: 15 additions & 44 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ preConfHook args config_flags = do
then rawSystemExit verbosity "git" ["submodule", "update", "--init", "--recursive"]
else do
-- XXX: This must be kept up to date with the git submodule revision
let archive = "v0.9.1.tar.gz"
let archive = "v0.11.1.tar.gz"
createDirectoryIfMissing True "cbits/tracy"
rawSystemExit verbosity "curl" ["-LO", "https://github.com/wolfpld/tracy/archive/refs/tags/" ++ archive]
rawSystemExit verbosity "tar" ["-xzf", archive, "-C", "cbits/tracy", "--strip-components", "1"]
Expand All @@ -59,61 +59,32 @@ postBuildHook args build_flags pkg_desc lbi = do
Platform _ os = hostPlatform lbi
verbosity = fromFlagOrDefault normal $ buildVerbosity build_flags
debugging = fromMaybe False $ lookupFlagAssignment (mkFlagName "debug") (configConfigurationsFlags config_flags)
targets = [ ("tracy-capture", "capture", "capture-release")
, ("tracy", "profiler", "Tracy-release") ]
targets = [ ("tracy-capture", "capture", "tracy-capture")
, ("tracy", "profiler", "tracy-profiler") ]

when debugging $ do
case os of
Windows -> return () -- XXX TODO: Windows users get the dummy executable that just throws an error
_ ->
forM_ targets $ \(hs_exe, c_dir, c_exe) -> do
let c_builddir = "cbits/tracy" </> c_dir </> "build/unix"
let c_projdir = "cbits/tracy" </> c_dir
hs_builddir = buildDir lbi </> hs_exe
c_tmpdir = c_builddir </> "obj"
hs_tmpdir = hs_builddir </> hs_exe ++ "-tmp"

setupMessage verbosity (printf "Building executable '%s' for" hs_exe) (package pkg_desc)
setupMessage verbosity (printf "Building executable '%s' from Tracy C++ sources for" hs_exe) (package pkg_desc)

-- Symlink the C build directory into the HS build directories.
-- We need to take care here: the symlink might already exist but point
-- to a nonexistent path, in which case doesDirectoryExist returns False
-- but it is still a symlink.
whenM (pathIsSymbolicLinkSafe c_tmpdir) $ removeFile c_tmpdir
objExists <- doesPathExist c_tmpdir
objExistsDir <- doesDirectoryExist c_tmpdir
createdObjSymlink <-
if | objExists && not objExistsDir ->
dieNoVerbosity $ c_tmpdir ++ " is a file; remove this to continue compiling accelerate."
| objExistsDir ->
return False
| otherwise -> do
-- Make the symlink (relative from c_builddir, hence the 5x ..)
createDirectoryLink ("../../../../.." </> hs_tmpdir) c_tmpdir
-- Create that temp directory if necessary. This is required if the accelerate
-- package is built as a dependency from another cabal project, because then only
-- the library is built, and not the executables such as tracy-capture.
createDirectoryIfMissing True hs_tmpdir
return True
-- TODO: This creates a separate build directory for each tracy
-- executable (of which we build two, at the time of writing). This
-- means that some duplicate work is done (building capstone twice).
-- Could we share a build directory between the two?

-- prevent having to re-link every time we build the library
executable <- doesFileExist (hs_builddir </> hs_exe)
when executable $ renameFile (hs_builddir </> hs_exe) (c_builddir </> c_exe)
rawSystemExit verbosity "cmake" ["-B", hs_tmpdir, "-S", c_projdir, "-DCMAKE_BUILD_TYPE=Release"]

-- build
rawSystemExit verbosity "make" ["-C", c_builddir]
-- Build in parallel with 2 jobs because likely, accelerate is one of
-- the last dependencies in a build, so we aren't stealing CPU time
-- from other packages, and tracy takes way too long to build
rawSystemExit verbosity "cmake" ["--build", hs_tmpdir, "--config", "Release", "-j", "2"]

-- move executable to the final destination
renameFile (c_builddir </> c_exe) (hs_builddir </> hs_exe)

-- clean up after ourselves
when createdObjSymlink $ removeDirectoryLink c_tmpdir
renameFile (hs_tmpdir </> c_exe) (hs_builddir </> hs_exe)

postBuild simpleUserHooks args build_flags pkg_desc lbi

-- | Returns True if there is a symbolic link at the given path, False otherwise.
pathIsSymbolicLinkSafe :: FilePath -> IO Bool
pathIsSymbolicLinkSafe fp =
handleDoesNotExist False $ pathIsSymbolicLink fp

whenM :: IO Bool -> IO () -> IO ()
whenM mcond action = mcond >>= \cond -> when cond action
29 changes: 12 additions & 17 deletions accelerate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,14 @@ extra-source-files:
cbits/tracy/public/client/*.hpp
cbits/tracy/public/client/*.cpp
-- These are used to build Tracy's client tools in Setup.hs
cbits/tracy/capture/build/unix/Makefile
cbits/tracy/capture/build/unix/*.mk
cbits/tracy/profiler/build/unix/Makefile
cbits/tracy/profiler/build/unix/*.mk
cbits/tracy/common/*.mk
-- The Makefiles fetch the source files from these Visual Studio project files
cbits/tracy/capture/build/win32/capture.vcxproj
cbits/tracy/capture/build/win32/capture.vcxproj.filters
cbits/tracy/profiler/build/win32/Tracy.vcxproj
cbits/tracy/profiler/build/win32/Tracy.vcxproj.filters
cbits/tracy/cmake/*.cmake
cbits/tracy/capture/CMakeLists.txt
cbits/tracy/profiler/CMakeLists.txt
-- Used by the Tracy's client tools
cbits/tracy/capture/src/*.cpp
cbits/tracy/dtl/*.hpp
cbits/tracy/getopt/*.c
cbits/tracy/getopt/*.h
cbits/tracy/imgui/*.cpp
cbits/tracy/imgui/*.h
cbits/tracy/imgui/misc/freetype/*.cpp
Expand All @@ -181,8 +176,9 @@ extra-source-files:
cbits/tracy/profiler/src/font/*.hpp
cbits/tracy/profiler/src/imgui/*.cpp
cbits/tracy/profiler/src/imgui/*.h
cbits/tracy/profiler/src/wayland/*.c
cbits/tracy/profiler/src/wayland/*.h
cbits/tracy/profiler/src/profiler/*.cpp
cbits/tracy/profiler/src/profiler/*.h
cbits/tracy/profiler/src/profiler/*.hpp
cbits/tracy/public/libbacktrace/*.cpp
cbits/tracy/public/libbacktrace/*.h
cbits/tracy/public/libbacktrace/*.hpp
Expand All @@ -194,7 +190,6 @@ extra-source-files:
cbits/tracy/zstd/common/*.h
cbits/tracy/zstd/compress/*.c
cbits/tracy/zstd/compress/*.h
cbits/tracy/zstd/decompress/*.S
cbits/tracy/zstd/decompress/*.c
cbits/tracy/zstd/decompress/*.h
cbits/tracy/zstd/dictBuilder/*.c
Expand All @@ -221,9 +216,9 @@ flag debug
built to collect and view profiling data from supported backends. This
requires several external dependencies:
.
* pkg-config
* camke
.
* capstone
* pkg-config
.
* freetype2
.
Expand All @@ -235,11 +230,11 @@ flag debug
.
For example on Debian/Ubuntu you can install all of these via:
.
> sudo apt install pkg-config libcapstone-dev libfreetype-dev libglfw3-dev libgtk-3-dev libtbb-dev
> sudo apt install cmake pkg-config libfreetype-dev libglfw3-dev libgtk-3-dev libtbb-dev
.
Or on macOS via:
.
> brew install pkg-config capstone freetype glfw
> brew install cmake pkg-config freetype glfw
.
With debugging enabled, applications will read the following options from
the environment variable @ACCELERATE_FLAGS@, and via the command-line as:
Expand Down
2 changes: 1 addition & 1 deletion cbits/tracy
Submodule tracy updated 327 files

0 comments on commit 0b9467f

Please sign in to comment.