Started by Matthew, January 16, 2020, 05:59:03 PM
0 Members and 1 Guest are viewing this topic.
sudo apt update
sudo apt-get build-dep openttdsudo apt install libbz2-devsudo apt install libsdl2-devsudo apt install libzstd-dev
QuoteIf you are using Fedora or CentOS, you might find the following works instead:Code Select Expandsudo yum-builddep openttdsudo yum install bzip2-develsudo yum install SDL2-devel
sudo yum-builddep openttdsudo yum install bzip2-develsudo yum install SDL2-devel
Quote from: Freahk on January 16, 2020, 07:34:27 PMOpen a terminal window e.g. by pressing F4 in Dolphin, launching Konsole or pressing Ctrl+Alt+F1 and elevate to root:Code Select ExpandsuNow refresh the repository cache and install the dependencies:Code Select Expandzypper refzypper in zlib-devel libbz2-devel libpng16-devel libSDL2-develLeave the root session:Code Select Expandexit
zypper refzypper in zlib-devel libbz2-devel libpng16-devel libSDL2-devel
QuoteIn openSUSE, Kubuntu, and other KDE distributions, open the working directory in Dolphin and then open a terminal pane (F4 on the keyboard).
sudo apt install gitgit clone https://github.com/jamespetts/simutrans-extended.git
QuoteIf you don't want to use Git, you can just download the ZIP file from James' Github repository. Click on the green "Clone or download" button on the right to see the ZIP link:Then extract the ZIP file into your working directory.
BACKEND = sdl2COLOUR_DEPTH = 16OSTYPE = linuxOPTIMISE = 1
ifneq ($(OPTIMISE),) CFLAGS += -O3 ifeq ($(findstring $(OSTYPE), amiga),) ifneq ($(findstring $(CXX), clang),) CFLAGS += -minline-all-stringops endif endifelse
Quote from: Freahk on January 16, 2020, 07:34:27 PMAlso, I want to add compile instructions for opensuse, feel free to add these to your post.
QuoteJames, are you sure there is any difference in optimise 1, 2, 3 or even "DONT"?
Quote from: jamespetts on January 18, 2020, 01:13:33 AMThis seems to duplicate the stickied version of this post - is this intended?
Quote from: Roboron on February 04, 2020, 03:05:30 PMAs I mentioned in other thread, I've created a PKGBUILD in the Arch Linux User Repository which automagically does all of this. It gets the source, the dependencies, applies some configuration patches, compiles the executable and installs Simutrans-Extended system-wide. Probably users of Arch Linux/Manjaro would prefer this over manual compiling (although you maybe don't want to compile Extended every day - but you also don't have to update if you don't want to).
BACKEND = sdl2COLOUR_DEPTH = 16OSTYPE = linuxDEBUG = 3OPTIMISE = 1
rm -r build
Quote from: FreahkYou can also open a terminal in your game directory and create a symlink to the just compiled binaryCode Select Expandcd <path to your simutrans installation>ln -s <path to your simutrans source root>/build/default/simutrans-extended simutrans-extended-devThis will create a symbolic link named simutrans-extended-dev linking to the place where the new binary will be placed after each compile. However, this will mean that you can only have one debug build at a time.
cd <path to your simutrans installation>ln -s <path to your simutrans source root>/build/default/simutrans-extended simutrans-extended-dev
sudo apt install perf
sudo apt updatesudo apt install linux-5.4-tools-commonsudo apt install linux-tools-common
sudo apt install linux-perf-5.4
suzypper refzypper in perfexit
sudo perf record -g ./simutrans-extended-debug
Quote from: FreahkIf you set up a symbolic link in step 8, open a terminal in your game directory and runCode Select Expandsudo perf record -g ./simutrans-extended-dev -use_workdir-use_workdir will tell simutrans to look for paksets and so on in the current working directory instead of the directory where the binary is placed.
sudo perf record -g ./simutrans-extended-dev -use_workdir
sudo pkill -9 simutrans
sudo perf report -g graph,0.05 --stdio > graph
sudo apt install perl
sudo perf script | ./stackcollapse-perf.pl > out.perf-foldedsudo grep -v cpu_idle out.perf-folded | ./flamegraph.pl > debug.svg
superf record -g ./simutrans-extended-dev -use_workdir
QuoteWhen you are using perf, you will not be able to close a crashed program in the usual ways.
pkill -9 simutrans
Quote from: Roboron on February 11, 2020, 12:53:26 PMWow, that's a very detailed and helpful explanation. I think it would be of great value if it were added to the Simutrans Wiki.
Quote from: Freahk on February 11, 2020, 03:53:38 PMThanks, that's a good tutorial I guess.
QuoteSome additions that might be helpful:In step 6 note that profiling should always be done on the optimized binary, as close as possible to the one you would "release".Thus,set MSG_LEVEL=0 to prevent simutrans spamming more than it would do in a non-debug build without explicitly set MSG_LEVEL andset DEBUG=1, which will add debug symbols and defines the DEBUG macro variable but nothing more.One could even argue about dropping the definition of the DEBUG macro, as there might be paths in the code that are only accessed #ifdef DEBUG, however my IDE couldn't find any, so it's fine.
ifdef DEBUG ifndef MSG_LEVEL MSG_LEVEL = 3 endif
QuoteInstead of step 8, navigate to yor simutrans installation dir and create a symlink to the just compiled binary
QuoteIn step 10, in the terminal navigate to your simutrans installation dir again.run Code Select Expandsudo perf record -g ./simutrans-extended-dev -use_workdir-use_workdir will tell simutrans to lok for paksets and so on in the current working directory instead of the directory where the binary is placed in.
QuoteYou might not need sudo. That depends on your systems kernel.perf_event_paranoid settings.
QuoteAbout the proces killing I am not quite sure what is going on.On my machine simutrans will simply crash, a coredump will be written and the process will terminate after it.However, generally looking up the pid and killing the process as described will work. However, there is an easyer way to do so and I am not quite sure why you cose the -7 signal, which is SIGBUS in linux x86, telling the process it had attempted to access a memory address that the hardware (cpus memory controller) physically cannot access.For a list of signals see "kill -l"I assume what yo are looking for is SIGKILL (-9) or SIGINT (-2)
QuoteThe mentioned easyer way is using pkill instead of kill.pkill will accept a process name pattern. Note that by default it will only match the first 16 chars of of the name. That's fine for us, we will simply kill any preceses that match simutrans.Code Select Expandpkill -9 simutrans
QuoteFurther I want to recommend installing and using htop instead of top.
Quote from: Matthew on February 11, 2020, 05:35:00 PMSo I think the MSG_LEVEL is going to be 3 for any Linux debug build, right?
Quote from: Matthew on February 11, 2020, 05:35:00 PMGood point, I forgot that not everybody has simutrans in /home.
Quote from: Matthew on February 11, 2020, 05:35:00 PMHappily, newbies don't need to worry about PIDs now that you have taught me about pkill!