diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-07-13 19:46:58 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-07-14 14:50:51 -0400 |
commit | adaea4136fdbf24933f243400f7771128f74deed (patch) | |
tree | 3dd45c9ce0f1122076d2d0800a926a914cba8df2 /test cases | |
parent | b92858a5beba687478e56850269bc89bc61b3954 (diff) | |
download | meson-adaea4136fdbf24933f243400f7771128f74deed.zip meson-adaea4136fdbf24933f243400f7771128f74deed.tar.gz meson-adaea4136fdbf24933f243400f7771128f74deed.tar.bz2 |
compiler.compiles/links: fix failure when compiling a built File object
In order to pass a File object down into the compiler impl and compile
it, we cannot pass a string with the filename, and we cannot either pass
the File object as-is, since it relies on being given Environment
attributes to calculate the relative location. So we build a fresh File
object as an absolute path.
But the code to do this was totally broken. Instead of using the File
method to get an absolute path, we used one that expected to create
builddir-relative paths... and then gave it the absolute source dir as
the "relative path portion" prefix. This worked by accident as long as
it wasn't a built File, but if it was a built file then we intentionally
didn't include that prefix -- which was wrong anyway, since we need the
build directory!
Use the correct method to get an absolute path in all cases, and emit a
warning if it was a built file. This never worked. Sometimes it crashed,
sometimes it silently returned false.
Fixes #11983
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/28 try compile/meson.build | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test cases/common/28 try compile/meson.build b/test cases/common/28 try compile/meson.build index cb41e1d..3480d1d 100644 --- a/test cases/common/28 try compile/meson.build +++ b/test cases/common/28 try compile/meson.build @@ -8,20 +8,27 @@ breakcode = '''#include<nonexisting.h> void func(void) { printf("This won't work.\n"); } ''' -foreach compiler : [meson.get_compiler('c'), meson.get_compiler('cpp')] - if compiler.compiles(code, name : 'should succeed') == false +foreach lang : ['c', 'cpp'] + compiler = meson.get_compiler(lang) + + if compiler.compiles(code, name : 'code should succeed') == false + error('Compiler ' + compiler.get_id() + ' is fail.') + endif + + if compiler.compiles(files('valid.c'), name : 'file should succeed') == false error('Compiler ' + compiler.get_id() + ' is fail.') endif - if compiler.compiles(files('valid.c'), name : 'should succeed') == false + copied = configure_file(input: 'valid.c', output: lang + '-valid-copy.c', copy: true) + if compiler.compiles(copied, name : 'built file should succeed') == false error('Compiler ' + compiler.get_id() + ' is fail.') endif - if compiler.compiles(breakcode, name : 'should fail') + if compiler.compiles(breakcode, name : 'code should fail') error('Compiler ' + compiler.get_id() + ' returned true on broken code.') endif - if compiler.compiles(files('invalid.c'), name : 'should fail') + if compiler.compiles(files('invalid.c'), name : 'file should fail') error('Compiler ' + compiler.get_id() + ' returned true on broken code.') endif endforeach |