-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compilers: Try harder to dedup builtin libs
-ldl, -lm, -lpthread should always be de-duplicated, no matter what. Closes #2150
- Loading branch information
Showing
11 changed files
with
97 additions
and
1 deletion.
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
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,13 @@ | ||
#include <stdio.h> | ||
#include <liba.h> | ||
#include <libb.h> | ||
|
||
int | ||
main(void) | ||
{ | ||
printf("start value = %d\n", liba_get()); | ||
liba_add(2); | ||
libb_mul(5); | ||
printf("end value = %d\n", liba_get()); | ||
return 0; | ||
} |
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,2 @@ | ||
executable('app', 'app.c', | ||
dependencies: [get_variable('dep_liba'), get_variable('dep_libb')]) |
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,18 @@ | ||
#include "liba.h" | ||
|
||
static int val; | ||
|
||
void liba_add(int x) | ||
{ | ||
val += x; | ||
} | ||
|
||
void liba_sub(int x) | ||
{ | ||
val -= x; | ||
} | ||
|
||
int liba_get(void) | ||
{ | ||
return val; | ||
} |
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,8 @@ | ||
#ifndef LIBA_H_ | ||
#define LIBA_H_ | ||
|
||
void liba_add(int x); | ||
void liba_sub(int x); | ||
int liba_get(void); | ||
|
||
#endif |
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,10 @@ | ||
deps = [dependency('threads'), cc.find_library('dl'), cc.find_library('m')] | ||
|
||
liba = library('a', 'liba.c', | ||
dependencies: deps) | ||
|
||
liba_dep = declare_dependency(link_with: liba, | ||
include_directories: include_directories('.'), | ||
dependencies: deps) | ||
|
||
set_variable('dep_liba', liba_dep) |
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,7 @@ | ||
#include <liba.h> | ||
#include "libb.h" | ||
|
||
void libb_mul(int x) | ||
{ | ||
liba_add(liba_get() * (x - 1)); | ||
} |
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 @@ | ||
#ifndef _LIBB_H_ | ||
#define _LIBB_H_ | ||
|
||
void libb_mul(int x); | ||
|
||
#endif |
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,9 @@ | ||
libb = library('b', 'libb.c', | ||
dependencies: liba_dep) | ||
|
||
libb_dep = declare_dependency(link_with: libb, | ||
include_directories: include_directories('.'), | ||
dependencies: liba_dep) | ||
|
||
set_variable('dep_libb', libb_dep) | ||
|
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,7 @@ | ||
project('temp', 'C') | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
subdir('liba') | ||
subdir('libb') | ||
subdir('app') |