-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add initial support for meson build system #1214
base: master
Are you sure you want to change the base?
Conversation
Thanks a lot for doing this! But the first impression is that it looks complicated. Maybe we can have a wrapper Makefile calling meson + ninja internally for the basic usecases? |
@gpollo Thanks for doing this work! I've tried to build it with meson, but see the following build error.
It seems that the related part is as follows. libmcount_arch = static_library(
'mcount-arch', [libmcount_arch_sources, libmcount_arch_asm_sources, version_h],
include_directories: [libmcount_arch_include],
c_args: [common_cflags],
pic: true,
)
libmcount_arch_dep = declare_dependency(
include_directories: [libmcount_arch_include],
# we link whole archive to overwrite weak symbols
link_args: ['-Wl,--whole-archive', 'libmcount-arch.a' , '-Wl,--no-whole-archive']
) It seems that it already builds By the way, is it really needed to make a static library |
@namhyung That's a good idea, I'll try to add some basic target in the current Makefile. @honggyukim Building the arch stuff in a separate lib should not longer be needed. I think I did it this way initially because |
Also you can change misc/install-deps.sh to have meson and ninja. |
Rebased the branch and removed the intermediate @honggyukim Turns out your build error was caused by |
@gpollo Thanks for the update. I've tested it again and see that the build is fine this time. But I see the default build generates And please properly rebase the patch on top of the current master. It seems that your last patch is on top of a wrong commit hash. |
98ad1b7
to
eb98e8d
Compare
|
Thanks a lot for the update! It looks good now, but I have a few more requests.
|
In other words, I think |
Alright, did some modifications again, hopefully, I didn't broke anything, I'll be testing more the upcoming weeks. Mainly,
|
Thanks for the update. I see
I will have a look at the details and your comment when I have more time. Thanks. |
I fixed it, commit 31d89ea added a new argument to |
Thanks for the update. It's getting closer to the complete set.
There is
To make the behavior same as
Can we make the value to boolean? I think
I see that In addition, So I would like to apply the following change although it didn't address all the points I mentioned. diff --git a/meson.build b/meson.build
index 660e8562..7700d6c0 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,8 @@ common_ldflags = []
uftrace_cflags = []
libmcount_cflags = []
demangler_cflags = []
+symbols_cflags = []
+dbginfo_cflags = []
traceevent_cflags = []
test_cflags = []
@@ -41,6 +43,8 @@ if get_option('trace')
trace_cflags = ['-pg', '-fno-omit-frame-pointer']
uftrace_cflags += trace_cflags
demangler_cflags += trace_cflags
+ symbols_cflags += trace_cflags
+ dbginfo_cflags += trace_cflags
traceevent_cflags += trace_cflags
test_cflags += trace_cflags
# cannot add -pg to libmcount_cflags because mcount() is not reentrant
@@ -55,15 +59,31 @@ libmcount_cflags
test_cflags += coverage_cflags
endif
+if get_option('asan')
+ asan_cflags = ['-O0', '-g', '-fsanitize=address,leak']
+ common_ldflags += ['-fsanitize=address,leak']
+
+ uftrace_cflags += asan_cflags
+ demangler_cflags += asan_cflags
+ symbols_cflags += asan_cflags
+ dbginfo_cflags += asan_cflags
+ traceevent_cflags += asan_cflags
+ test_cflags += asan_cflags
+endif
+
if get_option('sanitize') != ''
if get_option('sanitize') == 'all'
sanitize_cflags = ['-O0', '-g', '-fsanitize=address,leak,undefined']
+ common_ldflags += ['-fsanitize=address,leak,undefined']
else
sanitize_cflags = ['-O0', '-g', '-fsanitize=@0@'.format(get_option('sanitize'))]
+ common_ldflags += ['-fsanitize=@0@'.format(get_option('sanitize'))]
endif
uftrace_cflags += sanitize_cflags
demangler_cflags += sanitize_cflags
+ symbols_cflags += sanitize_cflags
+ dbginfo_cflags += sanitize_cflags
traceevent_cflags += sanitize_cflags
test_cflags += sanitize_cflags
endif
@@ -521,9 +541,9 @@ dbginfo_deps = [
dbginfo = executable(
'dbginfo', [dbginfo_sources],
dependencies: dbginfo_deps,
- c_args: [common_cflags],
+ c_args: [common_cflags, dbginfo_cflags],
link_args: [common_ldflags],
- build_by_default: false,
+ build_by_default: true,
)
#############
@@ -545,7 +565,42 @@ demangler = executable(
dependencies: demangler_deps,
c_args: [common_cflags, demangler_cflags],
link_args: [common_ldflags],
- build_by_default: false,
+ build_by_default: true,
+)
+
+###########
+# symbols #
+###########
+
+symbols_sources = [
+ 'misc/symbols.c',
+ 'utils/session.c',
+ 'utils/demangle.c',
+ 'utils/rbtree.c',
+ 'utils/utils.c',
+ 'utils/debug.c',
+ 'utils/filter.c',
+ 'utils/dwarf.c',
+ 'utils/auto-args.c',
+ 'utils/regs.c',
+ 'utils/argspec.c',
+ 'utils/symbol.c',
+ 'utils/symbol-libelf.c',
+ 'utils/symbol-rawelf.c',
+]
+symbols_deps = [
+ cxa_demangle_dep,
+ libdl_dep,
+ libdw_dep,
+ libelf_dep,
+]
+
+symbols = executable(
+ 'symbols', [symbols_sources],
+ dependencies: symbols_deps,
+ c_args: [common_cflags, symbols_cflags],
+ link_args: [common_ldflags],
+ build_by_default: true,
)
#########
diff --git a/meson_options.txt b/meson_options.txt
index b7acf797..d088940d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -112,9 +112,16 @@ option(
description: 'Enable code coverage',
)
+option(
+ 'asan',
+ type : 'boolean',
+ value : 'false',
+ description: 'Enable address sanitizer',
+)
+
option(
'sanitize',
type : 'string',
value : '',
description: 'Specify address and thread sanitizer options',
-)
\ No newline at end of file
+) @namhyung It'd be better if you could provide how you think. |
In addition,
|
I found one more. The
@namhyung I actually think it's better structure and can find the |
The problem with using An alternative solution using
You can use |
Sorry, I forgot some points.
Fixed it.
I think it depends on your system. For me (Arch Linux), the installation location was |
@gpollo Thanks very much for the update. I have two more requests.
I think it's almost done so @namhyung can take a look at the final review. I appreciate your work! |
Turns out that it can be done using
I didn't list the build options, be the command to list them is in the commit message. |
Fixed the python version. |
Thanks. I see that python version is fixed, but It even shows some errors |
That's weird, the original build system still seems to work here. Maybe there's some configurations in your shell? |
It's because my
Maybe we should explicitly specify shell name to diff --git a/misc/version.sh b/misc/version.sh
index 51b01b51..8a309463 100755
--- a/misc/version.sh
+++ b/misc/version.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
VERSION_FILE=$1
|
Thanks for working on this! I think we should change the logic in the check-deps to generate files under the build directory. Please check the check/build-dep-v1 branch. Also I think it'd be nice if it can work with any shell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see people looking into meson! I have some suggestions for your build files, hope this helps.
@eli-schwartz Thanks very much for your review in details. @gpollo Could you please have a look? If it takes a long time to address all the comments, maybe we can finalize the current PR and revisit addressing @eli-schwartz's comments in the follow up patch. |
Thank you @eli-schwartz for your detailed review! @honggyukim I think I'll leave the current commit as is since it replicated as much as possible the old build system. When transitionning to the build-in meson options, we can document the changes in the commit. I've already started on a few, they'll be in separate commits. |
Well, please at least fix the /bin/sh syntax errors :p And several other of my review comments pertained to using e.g. meson in-process string replacement rather than sed string replacement which is just all around good. |
I've fix most of @eli-schwartz comments. Again, thanks a lot! I've tried cross-compiling again (last time was before submitting this PR...). Removed the |
This build system goal is to replace the existing one based on makefiles. It is both faster and easier to maintain that the existing one. The following lists examples on how to configure and the build the project. Both `meson` and `ninja` commands are required. To use it, first create a build directory: $ mkdir build && cd build To configure build, execute one of these: $ meson .. # automatic configuration $ CC=clang meson .. # change compiler $ meson .. -Dwith-libpython=disabled To list options, execute: $ meson configure To reconfigure an existing build, execute: $ meson --reconfigure -Dwith-libpython=disabled To build uftrace, execute: $ ninja To install uftrace, execute one of these: # meson install # system directories $ DESTDIR=pkg meson install # building a package To run tests, execute: $ ninja unittest # run unit tests $ ninja runtest # run uftrace tests $ ninja tests # run unit and uftrace tests NOTE: Cross-compilation is rudimentary and not well-tested, but it is built-in in Meson [1]. For additional informations concerning Meson, see [2] or [3]. [1] https://mesonbuild.com/Cross-compilation.html [2] https://mesonbuild.com/howtox.html [3] https://mesonbuild.com/Quick-guide.html Signed-off-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>
Optisations level are also removed from debug build since they should be set using the built-in -Doptimization flag. See https://mesonbuild.com/Builtin-options.html#core-options
The Meson build system standardize the address sanitizer options for different compiler. In order to build with this feature, one must use the -Db_sanitize=... built-in option. See https://mesonbuild.com/Builtin-options.html#base-options
if arch == 'aarch64' | ||
libmcount_arch_include = include_directories('arch/aarch64') | ||
libmcount_arch_sources = [ | ||
'arch/aarch64/cpuinfo.c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be potentially rewritten
fs_mod = import('fs')
if fs_mod.is_dir('arch' / arch)
libmcount_arch_include = include_directories('arch' / arch)
subdir('arch' / arch)
else
error('target architecture `@0@` is not supported'.format(arch))
endif
inside arch/aarch64/meson.build
libmcount_arch_sources = files(
'cpuinfo.c',
'mcount-dynamic.c',
'mcount-insn.c',
'mcount-support.c',
)
libmcount_arch_asm_sources = files(
'dynamic.S',
'mcount.S',
'plthook.S',
)
], | ||
) | ||
|
||
run_target('tests', command: ['ninja', 'unittest', 'runtest']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In meson 0.60 you will be able to do this instead:
unittest = run_target(...)
runtest = run_target(...)
alias_target('tests', unittest, runtest)
@honggyukim I want to keep going this feature. |
@qpakzk thanks but you should address all the comments given by @eli-schwartz here. |
Ref: #189
In theory, all options from the old build system are supported, even cross-compilation as it is built-in
meson
.An example build commands could be:
You can list build options and configure them:
You can run tests:
For cross-compilation, you can read
meson
documentation. It involves creating a file with cross-compilation options. For example, this file can cross-compile ARM for the Raspberry-Pi 4.If the cross-build libraries are in
sys_root
, the build will find them. The application can be configured and build:Finally, it should be possible to install:
I marked the PR as WIP as I believe more testing could be done on it. It is possible that I forgot some compiler flags for certain targets and cross-compiling supports could be improved/tested more.