Skip to content

Commit

Permalink
tiny work on abi type locations, I am not sure how to compare the reg…
Browse files Browse the repository at this point in the history
…ister entries

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed May 3, 2021
1 parent ebdb8f8 commit 6a0de09
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
11 changes: 7 additions & 4 deletions lib/spack/spack/analyzers/elf/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def _generate_elf_symbol(self, corpus, symbol, meta, detail=False):
if bind == "LOCAL":
return

self.gen.fact(fn.symbol_definition(corpus.basename, symbol, defined))
self.gen.fact(fn.symbol_definition(corpus.basename, corpus.uid, symbol,
defined))
self.gen.fact(fn.has_symbol(corpus.basename, symbol))

if detail:
Expand Down Expand Up @@ -216,7 +217,7 @@ def _parse_die_children(self, corpus, die, parent=None):

# Parse common attributes of symbols
self._parse_common_attributes(corpus, die, tag)

# We keep a handle on the root to return
if not parent:
parent = die.unique_id
Expand Down Expand Up @@ -551,11 +552,13 @@ def generate_corpus_metadata(self, corpora, main):

# Is it a main corpus?
if corpus.name == main:
self.gen.fact(fn.is_main_corpus(corpus.name, corpus.uid))
self.gen.fact(fn.is_main_corpus(corpus.name, corpus.basename,
corpus.uid))

# If the corpus has a soname:
if corpus.soname:
self.gen.fact(fn.corpus_soname(corpus.name, corpus.soname))
self.gen.fact(fn.corpus_soname(corpus.name, corpus.basename,
corpus.soname))

# e_machine is the required architecture for the file
self.gen.fact(fn.corpus_machine(corpus.name, hdr["e_machine"]))
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/cmd/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setup_parser(subparser):
# Assume for now that we can only add one extra model
subparser.add_argument(
'-e', '--extra', action='store',
default=None, choices=['symbols'],
default=None, choices=['symbols', 'abi_type_location'],
help='extra known models to add to the solve.')
subparser.add_argument(
'-p', '--lp', default=None,
Expand Down
57 changes: 52 additions & 5 deletions lib/spack/spack/solver/logic/locationtype.lp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ undefined_symbol(Package, Version, Symbol, Corpus)
% and it's definition is UND
symbol_definition(Corpus, Symbol, "UND").


% a symbol is undefined for a package version if
undefined_symbol(Package, Version, Symbol)

Expand Down Expand Up @@ -85,17 +86,22 @@ linkable(Package, Dependency)

% And the dependency holds
dependency_holds(Package, Dependency, _).


% A package and dependency are incompatible if:
incompatible(Package, V1, Dependency, V2)
% base rule for incompatible
incompatible_base(Package, V1, Dependency, V2)

% they are linkable
:- linkable(Package, Dependency),

% The package and dependency each have their own version
version(Package, V1),
version(Dependency, V2),
version(Dependency, V2).


% A package and dependency are incompatible if:
incompatible(Package, V1, Dependency, V2)

:- incompatible_base(Package, V1, Dependency, V2),

% The package has an undefined symbol
undefined_symbol(Package, V1, Symbol),
Expand All @@ -105,5 +111,46 @@ incompatible(Package, V1, Dependency, V2)

% and the symbol is not defined for the dependency
not defined_symbol(Dependency, V2, Symbol).



% incompatible if matching variables are different types
% abi_typelocation("variable","libtcl8.6.so","environ","export","char").
incompatible(Package, V1, Corpus1, Type1, Dependency, V2, Corpus2, Variable, Type2, VariableType)

:- incompatible_base(Package, V1, Dependency, V2),

% it's a variable needed (imported) by Corpus1
abi_typelocation(VariableType, Corpus1, Variable, "import", Type1),

% it's exported by Corpus 2
abi_typelocation(VariableType, Corpus2, Variable, "export", Type2),

% but the type is wrong
Type1 != Type2.

% flatten into the rule that fits into solver
incompatible(Package, V1, Dependency, V2)

% we don't care about the corpus, variable name, or type
:- incompatible(Package, V1, _, _, Dependency, V2, _, _, _, _).

% abi_typelocation("variable","libtcl8.6.so","graphCharTable","export","short unsigned int","(DW_OP_addr: 206660)").

% Not sure how to compare the last variables
% abi_typelocation("function","libtcl8.6.so","carc_cmp","export","int","%rax").
% incompatile if their locations are off
%incompatible(Package, V1, Corpus1, Type1, Dependency, V2, Corpus2, Variable, Type2, VariableType)

% :- incompatible_base(Package, V1, Dependency, V2),

% it's a variable needed (imported) by Corpus1
% abi_typelocation(VariableType, Corpus1, Variable, "import", Type1),

% it's exported by Corpus 2
% abi_typelocation(VariableType, Corpus2, Variable, "export", Type2),

% but the type is wrong
% Type1 != Type2.


#show incompatible/4.

0 comments on commit 6a0de09

Please sign in to comment.