-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add compilers from extracted objects directly to build targets
In order to reliably link to static libraries or individual object files, we need to take their languages into account as well. For static libraries this is easy: we just add the static library's list of compilers to the build target. For extracted objects, we need to only add the ones for the objects we use. But we did this really inefficiently -- in fact, downright terribly. We iterated over all source files from the extracted objects, then tried to look up a new compiler for them. Even though the extracted objects already had a list of compilers! This broke once compilers were made per-subproject, because while the extracted objects have a reference to all the compilers it needs (just like static archives do, actually) we might not actually be able to look up that compiler from scratch inside the current subproject. Fix this by asking the extracted objects to categorize all its own sources and return the compilers we want. Fixes #10579
- Loading branch information
1 parent
ce9364d
commit 62a95ef
Showing
7 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define DLL_IMPORT __declspec(dllimport) | ||
#else | ||
#define DLL_IMPORT | ||
#endif | ||
|
||
int DLL_IMPORT cppfunc(void); | ||
|
||
int otherfunc(void) { | ||
return cppfunc() != 42; | ||
} |
5 changes: 5 additions & 0 deletions
5
test cases/common/253 subproject extracted objects/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project('link to extracted objects', 'c') | ||
|
||
sublib = subproject('myobjects').get_variable('sublib') | ||
|
||
mainlib = static_library('foo', 'foo.c', install: true, link_with: sublib) |
6 changes: 6 additions & 0 deletions
6
test cases/common/253 subproject extracted objects/subprojects/myobjects/cpplib.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#define BUILDING_DLL | ||
#include "cpplib.h" | ||
|
||
extern "C" int DLL_PUBLIC cppfunc(void) { | ||
return 42; | ||
} |
12 changes: 12 additions & 0 deletions
12
test cases/common/253 subproject extracted objects/subprojects/myobjects/cpplib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* See http://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support */ | ||
#if defined(_WIN32) || defined(__CYGWIN__) | ||
#ifdef BUILDING_DLL | ||
#define DLL_PUBLIC __declspec(dllexport) | ||
#else | ||
#define DLL_PUBLIC __declspec(dllimport) | ||
#endif | ||
#else | ||
#define DLL_PUBLIC __attribute__ ((visibility ("default"))) | ||
#endif | ||
|
||
extern "C" int DLL_PUBLIC cppfunc(void); |
3 changes: 3 additions & 0 deletions
3
test cases/common/253 subproject extracted objects/subprojects/myobjects/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project('myobjects', 'cpp') | ||
|
||
sublib = static_library('sublib', 'cpplib.cpp') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"installed": [ | ||
{ "type": "file", "file": "usr/lib/libfoo.a" } | ||
] | ||
} |