forked from omnigres/omnigres
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: overriding postgres symbols
Solution: add a target that checks if Postgres and a Postgres extension have conflicting symbols. If conflicting symbols are detected the build shall fail.
- Loading branch information
Showing
2 changed files
with
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import platform | ||
import subprocess | ||
import sys | ||
|
||
|
||
def get_symbols(binary): | ||
symbols = set() | ||
args = ["nm"] | ||
if platform.system() == "Darwin": | ||
args += ["-g", "-U", binary] | ||
elif platform.system() == "Linux": | ||
args += ["-g", "--defined-only", binary] | ||
else: | ||
raise Exception("Unsupported platform %s" % platform.system()) | ||
res = subprocess.run(args, stdout=subprocess.PIPE) | ||
for line in res.stdout.decode("utf-8").split("\n"): | ||
# skip over empty lines and lines that are not symbols | ||
if line.strip() and "for architecture" not in line: | ||
symbols.add(line.split(" ")[2]) | ||
return symbols | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 3: | ||
print("Usage: %s <binary1> <binary2>" % sys.argv[0]) | ||
sys.exit(1) | ||
binary1, binary2 = sys.argv[1:] | ||
symbols1 = get_symbols(binary1) | ||
symbols2 = get_symbols(binary2) | ||
intersection = symbols1 & symbols2 | ||
if symbols1 & symbols2: | ||
sys.stderr.write("Found symbols that are present in both binaries:\n") | ||
sys.stderr.write("\n".join(intersection)) | ||
sys.exit(1) |