Check for manual attempts to set rpath and update docs.

pull/2063/head
Jussi Pakkanen 7 years ago
parent 2269b7f60b
commit e82edc179f
  1. 1
      docs/markdown/Reference-manual.md
  2. 11
      docs/markdown/Release-notes-for-0.42.0.md
  3. 4
      mesonbuild/build.py
  4. 14
      test cases/linuxlike/7 library versions/meson.build

@ -243,6 +243,7 @@ Executable supports the following keyword arguments. Note that just like the pos
- `extra_files` are not used for the build itself but are shown as source files in IDEs that group files by targets (such as Visual Studio)
- `install`, when set to true, this executable should be installed
- `install_rpath` a string to set the target's rpath to after install (but *not* before that)
- `build_rpath` a string to add to target's rpath definition in the build dir, but which will be removed on install
- `install_dir` override install directory for this file. The value is relative to the `prefix` specified. F.ex, if you want to install plugins into a subdir, you'd use something like this: `install_dir : get_option('libdir') + '/projectname-1.0'`.
- `objects` list of prebuilt object files (usually for third party products you don't have source to) that should be linked in this target, **never** use this for object files that you build yourself.
- `name_suffix` the string that will be used as the extension for the target by overriding the default. By default on Windows this is `exe` and on other platforms it is omitted.

@ -65,3 +65,14 @@ A new experimental module to compile code with many different SIMD
instruction sets and selecting the best one at runtime. This module
is unstable, meaning its API is subject to change in later releases.
It might also be removed altogether.
## Added build_rpath keyword argument
You can specify `build_rpath : '/foo/bar'` in build targets and the
given path will get added to the target's rpath in the build tree. It
is removed during the install step.
Meson will print a warning when the user tries to add an rpath linker
flag manually, e.g. via `link_args` to a target. This is not
recommended because having multiple rpath causes them to stomp on each
other. This warning will become a hard error in some future release.

@ -670,6 +670,10 @@ class BuildTarget(Target):
for i in self.link_args:
if not isinstance(i, str):
raise InvalidArguments('Link_args arguments must be strings.')
for l in self.link_args:
if '-Wl,-rpath' in l or l.startswith('-rpath'):
mlog.warning('''Please do not define rpath with a linker argument, use install_rpath or build_rpath properties instead.
This will become a hard error in a future Meson release.''')
self.process_link_depends(kwargs.get('link_depends', []), environment)
# Target-specific include dirs must be added BEFORE include dirs from
# internal deps (added inside self.add_deps()) to override them.

@ -32,20 +32,24 @@ out = custom_target('library-dependency-hack',
# Need to add this manually because Meson can't add it automatically because
# it doesn't know that we are linking to libraries in the build directory.
rpath_arg = '-Wl,-rpath,' + meson.current_build_dir()
rpath_dir = meson.current_build_dir()
# Manually test if the linker can find the above libraries
# i.e., whether they were generated with the right naming scheme
test('manually linked 1', executable('manuallink1', out,
link_args : ['-L.', '-lsome', rpath_arg]))
link_args : ['-L.', '-lsome'],
build_rpath : rpath_dir))
test('manually linked 2', executable('manuallink2', out,
link_args : ['-L.', '-lnoversion', rpath_arg]))
link_args : ['-L.', '-lnoversion'],
build_rpath : rpath_dir))
test('manually linked 3', executable('manuallink3', out,
link_args : ['-L.', '-lonlyversion', rpath_arg]))
link_args : ['-L.', '-lonlyversion'],
build_rpath : rpath_dir))
test('manually linked 4', executable('manuallink4', out,
link_args : ['-L.', '-lonlysoversion', rpath_arg]))
link_args : ['-L.', '-lonlysoversion'],
build_rpath : rpath_dir))
shared_module('module', 'lib.c', install : true)

Loading…
Cancel
Save