opencog / opencog-nix

Build definitions for the NIX package manager
7 stars 4 forks source link

[atomspace] build throws (in namespace '::' does not name a type friend class) #54

Closed Radivarig closed 4 years ago

Radivarig commented 4 years ago

After this commit, atomspace build throws a big number of errors, and the same is for the last commit.

I tried removing the double colon "::" in the first error friend class ::ClassServerUTest like in the fix for #50 and it doesn't throw that one, but still goes on to throw all the rest of the errors so there must be something I'm missing.

cmake flags: -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DCMAKE_INSTALL_INCLUDEDIR=/run/user/1000/tmp.mkPPf3GSaD/include -DCMAKE_INSTALL_LIBDIR=/run/user/1000/tmp.mkPPf3GSaD/lib -DCMAKE_INSTALL_NAME_DIR=/run/user/1000/tmp.mkPPf3GSaD/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=last -DCMAKE_STRIP=/nix/store/aymbjlfqiqy3v536zia24m6bszc9mkpi-binutils-2.31.1/bin/strip -DCMAKE_RANLIB=/nix/store/aymbjlfqiqy3v536zia24m6bszc9mkpi-binutils-2.31.1/bin/ranlib -DCMAKE_AR=/nix/store/aymbjlfqiqy3v536zia24m6bszc9mkpi-binutils-2.31.1/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/run/user/1000/tmp.mkPPf3GSaD -DGUILE_INCLUDE_DIR:PATH=/nix/store/3jl1ldm0lviczjfshah9ab6dffa5qsh3-guile-2.2.3-dev/include/guile/2.2 -DGMP_INCLUDE_DIR:PATH=/nix/store/dgm5m7kmpd5vp7kspz97hc07rdrkzmsd-gmp-6.1.2-dev/include -DGUILE_SITE_DIR:PATH=share/guile/site -DPYTHON_DEST:PATH=lib/python3.6/site-packages -DCXXTEST_BIN_DIR:PATH=/nix/store/cs5gr9csr29ks6gpi7wkwwrf7kf1a3i9-cxxtest-4.4/bin -DCPLUS_INCLUDE_PATH:PATH=/nix/store/fs3xkh3a36xn00p4s2wdzm9xrhrghm5w-source 
CMake Deprecation Warning at CMakeLists.txt:18 (CMAKE_POLICY):
  The OLD behavior for policy CMP0037 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /nix/store/kivwik98k5llwmn7mzizj604j481pa55-gcc-wrapper-7.4.0/bin/gcc
-- Check for working C compiler: /nix/store/kivwik98k5llwmn7mzizj604j481pa55-gcc-wrapper-7.4.0/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /nix/store/kivwik98k5llwmn7mzizj604j481pa55-gcc-wrapper-7.4.0/bin/g++
-- Check for working CXX compiler: /nix/store/kivwik98k5llwmn7mzizj604j481pa55-gcc-wrapper-7.4.0/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build type: Release
-- CogUtil version 2.0.3 found.
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   filesystem
--   system
-- Boost version 106600 found.
-- Found PythonInterp: /nix/store/mw636p9yg8ba8mmvrgiw1x1mda69pyws-python-2.7.17/bin/python (found version "2.7.17") 
-- CxxTest found.
-- Gearman not found.
-- Guile (2.2.3 >= 2.2.2) was found.
-- Looking for secure_getenv
-- Looking for secure_getenv - not found
-- Found Python3Interp: /nix/store/p9ikwbfdfkp04i4hz00bf4fd0km1vds2-python3-3.6.9/bin/python3  
-- Python 3.6.9 interpreter found.
-- Found PythonLibs: /nix/store/p9ikwbfdfkp04i4hz00bf4fd0km1vds2-python3-3.6.9/lib/libpython3.6m.so (found version "3.6.9") 
-- Python 3.6.9 libraries found.
-- Found PythonInterp: /nix/store/p9ikwbfdfkp04i4hz00bf4fd0km1vds2-python3-3.6.9/bin/python3.6 (found version "3.6.9") 
-- Found Cython: /nix/store/ba69dp4vxn93q48sbdlc3rrnvm7cm5x2-python3.6-Cython-0.29.5/bin/cython (Required is at least version "0.23.0") 
-- Cython ( 0.29.5 >= 0.23.0) found.
/nix/store/p9ikwbfdfkp04i4hz00bf4fd0km1vds2-python3-3.6.9/lib/python3.6/site-packages
-- Python destination dir found: lib/python3.6/site-packages
-- Python install dir: lib/python3.6/site-packages/opencog
-- Using nosetests executable /nix/store/2xyn8d0f2y8dlyn9vgj0ksmb2n52i1k9-python3.6-nose-1.3.7/bin/nosetests
-- Stack was not found. Haskell bindings will not be built.
-- UnixODBC was not found; ODBC persistence subsystem will not be built.
To over-ride, make sure UnixODBC_LIBRARIES and UnixODBC_INCLUDE_DIRS are set.
-- Found PGSQL: /nix/store/1jkvhal89a82kavawyaa7abl5115ddzd-postgresql-9.6.15-lib/lib/libpq.so (found suitable version "9.6.15", minimum required is "9.5") 
-- PostgresSQL 9.6.15 was found.
-- Valgrind Prefix: 
-- Could NOT find VALGRIND (missing: VALGRIND_INCLUDE_DIR VALGRIND_PROGRAM) 
-- VALGRIND missing: needed for thread debugging.
-- Required version of ZeroMQ was not found. Make sure the ZMQ_LIBRARY environment variable is set.
-- ZeroMQ library or its C++ header file was not found; 
To over-ride, make sure that the environment variable ZMQ_LIBRARY is set.
Installation instructions: http://zeromq.org/intro:get-the-software
-- Setting python RPATH to lib/python3.6/site-packages/opencog
-- Postgres database is configured for unit tests.
-- found cython and nosetest, enabling python unit tests
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Doxygen not found, you won't be able to generate API documentation.

Building for NixOS 19.03.173666.68d058e64aa (Koi)

The following components will be built:
-----------------------------------------------
   AtomSpace              - A weighted and typed graph database.
   Python bindings        - Python (cython) bindings.
   Python tests           - Python bindings nose tests.
   Scheme bindings        - Scheme bindings and shell.
   SQL Postgres bindings  - Save/Restore of AtomSpace to Postgres database.
   Unit tests             - Unit tests.

The following components WILL NOT be built:
-----------------------------------------------
   Doxygen                - Code documentation.
   Gearman                - Distributed processing capability.
   Haskell bindings       - Haskell bindings.
   SQL ODBC bindings      - Save/Restore of AtomSpace to database via ODBC.

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_INSTALL_INCLUDEDIR
    CMAKE_INSTALL_LIBDIR
    CPLUS_INCLUDE_PATH
    CXXTEST_BIN_DIR

-- Build files have been written to: /home/radivarig/projects/opencog-dev/source/build
cmake: enabled parallel building
building
build flags: -j8 -l8 SHELL=/nix/store/rn5dmlak31vg3fjv94y8gwy1pn6vbdab-bash-interactive-4.4-p23/bin/bash
Scanning dependencies of target opencog_atom_types
Scanning dependencies of target persist-pg
Scanning dependencies of target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_scm
[  0%] Cythonizing logger.pyx
Scanning dependencies of target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_matrix
Scanning dependencies of target SCM_CONFIG
Scanning dependencies of target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_sheaf
Scanning dependencies of target executioncontext
[  0%] Built target SCM_CONFIG
[  0%] Generating opencog types
[  0%] Building CXX object opencog/persist/sql/multi-driver/CMakeFiles/persist-pg.dir/ll-pg-cxx.cc.o
-- Atom type name: Notype Notype
-- Atom type name: Value Value
-- Atom type name: FloatValue FloatValue
-- Atom type name: StringValue StringValue
-- Atom type name: LinkValue LinkValue
-- Atom type name: Valuation Valuation
-- Atom type name: TruthValue TruthValue
-- Atom type name: SimpleTruthValue SimpleTruthValue
-- Atom type name: CountTruthValue CountTruthValue
-- Atom type name: IndefiniteTruthValue IndefiniteTruthValue
-- Atom type name: FuzzyTruthValue FuzzyTruthValue
-- Atom type name: ProbabilisticTruthValue ProbabilisticTruthValue
-- Atom type name: EvidenceCountTruthValue EvidenceCountTruthValue
-- Atom type name: StreamValue StreamValue
-- Atom type name: RandomStream RandomStream
-- Atom type name: Atom Atom
-- Atom type name: Node 
-- Atom type name: Link 
-- Atom type name: ConceptNode Concept
-- Atom type name: NumberNode Number
-- Atom type name: OrderedLink Ordered
-- Atom type name: UnorderedLink Unordered
-- Atom type name: PredicateNode Predicate
-- Atom type name: EvaluatableLink Evaluatable
[  0%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_sheaf
-- Atom type name: CrispOutputLink CrispOutput
-- Atom type name: NumericOutputLink NumericOutput
[  0%] Building CXX object opencog/executioncontext/CMakeFiles/executioncontext.dir/Context.cc.o
-- Atom type name: BooleanLink Boolean
-- Atom type name: NumericLink Numeric
-- Atom type name: TypeLink Type
-- Atom type name: TypeOutputLink TypeOutput
-- Atom type name: SetLink Set
-- Atom type name: ListLink List
-- Atom type name: MemberLink Member
-- Atom type name: ContextLink Context
-- Atom type name: TrueLink True
-- Atom type name: FalseLink False
-- Atom type name: AndLink And
-- Atom type name: OrLink Or
-- Atom type name: NotLink Not
-- Atom type name: SequentialAndLink SequentialAnd
-- Atom type name: SequentialOrLink SequentialOr
-- Atom type name: ChoiceLink Choice
-- Atom type name: PresentLink Present
-- Atom type name: AbsentLink Absent
-- Atom type name: AlwaysLink Always
-- Atom type name: ParallelLink Parallel
-- Atom type name: JoinLink Join
-- Atom type name: VariableNode Variable
-- Atom type name: VariableList VariableList
-- Atom type name: VariableSet VariableSet
-- Atom type name: GlobNode Glob
-- Atom type name: QuoteLink Quote
-- Atom type name: UnquoteLink Unquote
-- Atom type name: LocalQuoteLink LocalQuote
-- Atom type name: DontExecLink DontExec
-- Atom type name: FreeLink Free
-- Atom type name: DeleteLink Delete
-- Atom type name: UniqueLink Unique
-- Atom type name: StateLink State
-- Atom type name: DefineLink Define
-- Atom type name: ScopeLink Scope
-- Atom type name: RewriteLink Rewrite
-- Atom type name: PrenexLink Prenex
-- Atom type name: LambdaLink Lambda
-- Atom type name: PutLink Put
-- Atom type name: PatternLink Pattern
-- Atom type name: SatisfyingLink Satisfying
-- Atom type name: GetLink Get
-- Atom type name: QueryLink Query
-- Atom type name: BindLink Bind
-- Atom type name: DualLink Dual
-- Atom type name: EvaluationLink Evaluation
-- Atom type name: EquivalenceLink Equivalence
-- Atom type name: TypeNode Type
-- Atom type name: TypeInhNode TypeInh
-- Atom type name: TypeCoInhNode TypeCoInh
-- Atom type name: DefinedTypeNode DefinedType
-- Atom type name: TypeChoice TypeChoice
-- Atom type name: TypeSetLink TypeSet
-- Atom type name: ArrowLink Arrow
-- Atom type name: SignatureLink Signature
-- Atom type name: FuzzyLink Fuzzy
-- Atom type name: TypedVariableLink TypedVariable
[  0%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_matrix
-- Atom type name: TypedAtomLink TypedAtom
-- Atom type name: IntervalLink Interval
-- Atom type name: AnchorNode Anchor
-- Atom type name: VirtualLink Virtual
-- Atom type name: GreaterThanLink GreaterThan
-- Atom type name: IdenticalLink Identical
-- Atom type name: EqualLink Equal
-- Atom type name: AlphaEqualLink AlphaEqual
-- Atom type name: SatisfactionLink Satisfaction
-- Atom type name: FunctionLink Function
-- Atom type name: ExecutionOutputLink ExecutionOutput
-- Atom type name: ValueOfLink ValueOf
-- Atom type name: TruthValueOfLink TruthValueOf
-- Atom type name: StrengthOfLink StrengthOf
-- Atom type name: ConfidenceOfLink ConfidenceOf
-- Atom type name: AttentionValueOfLink AttentionValueOf
-- Atom type name: StiOfLink StiOf
-- Atom type name: LtiOfLink LtiOf
[  0%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_scm
-- Atom type name: PredicateFormulaLink PredicateFormula
-- Atom type name: FoldLink Fold
-- Atom type name: ArithmeticLink Arithmetic
-- Atom type name: PlusLink Plus
-- Atom type name: MinusLink Minus
-- Atom type name: TimesLink Times
-- Atom type name: DivideLink Divide
-- Atom type name: RandomNumberLink RandomNumber
-- Atom type name: ArityLink Arity
-- Atom type name: RandomChoiceLink RandomChoice
-- Atom type name: TimeLink Time
-- Atom type name: CondLink Cond
-- Atom type name: SleepLink Sleep
-- Atom type name: MapLink Map
-- Atom type name: Connector Connector
-- Custom atom type name specified: "ConnectorDir"
-- Atom type name: ConnectorDir ConnectorDir
-- Custom atom type name specified: "LinkClass"
-- Atom type name: LinkClass LinkClass
-- Atom type name: ConnectorSeq ConnectorSeq
-- Atom type name: Section Section
-- Atom type name: ProcedureNode Procedure
-- Atom type name: GroundedProcedureNode GroundedProcedure
-- Atom type name: SchemaNode Schema
-- Atom type name: DefinedSchemaNode DefinedSchema
-- Atom type name: GroundedSchemaNode GroundedSchema
-- Atom type name: DefinedPredicateNode DefinedPredicate
-- Atom type name: GroundedPredicateNode GroundedPredicate
-- Atom type name: QuantityLink Quantity
-- Atom type name: InheritanceLink Inheritance
-- Atom type name: SubsetLink Subset
-- Atom type name: IntensionalInheritanceLink IntensionalInheritance
-- Atom type name: SimilarityLink Similarity
-- Atom type name: ExtensionalSimilarityLink ExtensionalSimilarity
-- Atom type name: IntensionalSimilarityLink IntensionalSimilarity
-- Custom atom type name specified: "ForAllLink"
-- Atom type name: ForAllLink ForAll
-- Atom type name: ExistsLink Exists
-- Atom type name: SatisfyingSetScopeLink SatisfyingSetScope
-- Atom type name: SatisfyingSetLink SatisfyingSet
-- Atom type name: ImplicationScopeLink ImplicationScope
-- Atom type name: IntensionalImplicationScopeLink IntensionalImplicationScope
-- Atom type name: ExtensionalImplicationScopeLink ExtensionalImplicationScope
-- Atom type name: EquivalenceScopeLink EquivalenceScope
-- Atom type name: IntensionalEquivalenceScopeLink IntensionalEquivalenceScope
-- Atom type name: ExtensionalEquivalenceScopeLink ExtensionalEquivalenceScope
-- Atom type name: ImplicationLink Implication
-- Atom type name: IntensionalImplicationLink IntensionalImplication
-- Atom type name: ExtensionalImplicationLink ExtensionalImplication
-- Atom type name: IntensionalEquivalenceLink IntensionalEquivalence
-- Atom type name: ExtensionalEquivalenceLink ExtensionalEquivalence
-- Atom type name: AssociativeLink Associative
-- Atom type name: AttractionLink Attraction
-- Atom type name: ExecutionLink Execution
[  0%] Built target opencog_atom_types
Scanning dependencies of target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_atoms_atom_types
Scanning dependencies of target py_atomspace_header
Scanning dependencies of target atom_types
[  0%] Cythonizing atomspace.pyx
[  0%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/atom_types_init.cc.o
[  0%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/NameServer.cc.o
[  0%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_atoms_atom_types
Scanning dependencies of target logger_cython
[  0%] Building CXX object opencog/cython/opencog/CMakeFiles/logger_cython.dir/logger.cpp.o
[  3%] Linking CXX shared library libpersist-pg.so
[  3%] Built target persist-pg
In file included from /home/radivarig/projects/opencog-dev/source/opencog/atoms/value/Value.h:31:0,
                 from /home/radivarig/projects/opencog-dev/source/opencog/atoms/value/FloatValue.h:27,
                 from /home/radivarig/projects/opencog-dev/source/opencog/atoms/truthvalue/TruthValue.h:35,
                 from /home/radivarig/projects/opencog-dev/source/opencog/atomspace/AtomSpace.h:31,
                 from /home/radivarig/projects/opencog-dev/source/opencog/executioncontext/Context.h:1,
                 from /home/radivarig/projects/opencog-dev/source/opencog/executioncontext/Context.cc:1:
/home/radivarig/projects/opencog-dev/source/opencog/atoms/atom_types/NameServer.h:52:20: error: 'ClassServerUTest' in namespace '::' does not name a type
     friend class ::ClassServerUTest;
                    ^~~~~~~~~~~~~~~~
/home/radivarig/projects/opencog-dev/source/opencog/atoms/atom_types/NameServer.h:52:5: error: friend declaration does not name a class or function
     friend class ::ClassServerUTest;
     ^~~~~~
In file included from /home/radivarig/projects/opencog-dev/source/opencog/atoms/value/FloatValue.h:28:0,
                 from /home/radivarig/projects/opencog-dev/source/opencog/atoms/truthvalue/TruthValue.h:35,
                 from /home/radivarig/projects/opencog-dev/source/opencog/atomspace/AtomSpace.h:31,
                 from /home/radivarig/projects/opencog-dev/source/opencog/executioncontext/Context.h:1,
                 from /home/radivarig/projects/opencog-dev/source/opencog/executioncontext/Context.cc:1:
/home/radivarig/projects/opencog-dev/source/build/opencog/atoms/atom_types/atom_types.h:10:17: error: 'Type' in namespace 'opencog::opencog' does not name a type
 extern opencog::Type VALUE;
                 ^~~~
/home/radivarig/projects/opencog-dev/source/build/opencog/atoms/atom_types/atom_types.h:11:17: error: 'Type' in namespace 'opencog::opencog' does not name a type
 extern opencog::Type FLOAT_VALUE;
                 ^~~~
/home/radivarig/projects/opencog-dev/source/build/opencog/atoms/atom_types/atom_types.h:12:17: error: 'Type' in namespace 'opencog::opencog' does not name a type
 extern opencog::Type STRING_VALUE;
                 ^~~~
/home/radivarig/projects/opencog-dev/source/build/opencog/atoms/atom_types/atom_types.h:13:17: error: 'Type' in namespace 'opencog::opencog' does not name a type
 extern opencog::Type LINK_VALUE;
                 ^~~~
...
linas commented 4 years ago

This suggests that some header file accidentally says using namespace opencog but grapping doesn't find this.

Another possibility: somewhere in a header file there is a namespace opencog { without a matching } to close it. The reason for this is this error:

error: 'Type' in namespace 'opencog::opencog'
extern opencog::Type

There's no such thing as namespace opencog::opencog so the fact that it's doubled is suggesting the root cause.

(Of course, things seem to work fine, for me)

linas commented 4 years ago

oh wait, I think I know what it is ... I think I've seen it ...

you have to give it time to let the atom-types get build, before saying make -j to compile the rest.

The atom-types used to be handled correctly as a dependency, but maybe this broke recently.

Radivarig commented 4 years ago

Correct, it builds with enableParallelBuilding = false

linas commented 4 years ago

The root cause is that the build of NameServer.o starts before the generation of atom_types.h has finished.
And thus, the closing brace on namespace opencog has not yet been written to the header file; without that closing brace, everything gets confused.

linas commented 4 years ago

OK, hoping that opencog/atomspace#2448 fixes this

Radivarig commented 4 years ago

Still the same, I've also tried to build by hand step by step:

unpackPhase && cd source
mkdir build && cd build
cmake $cmakeFlags ..
make -j # same error

cmake flags

-DGUILE_INCLUDE_DIR:PATH=/nix/store/...-guile-2.2.3-dev/include/guile/2.2
-DGMP_INCLUDE_DIR:PATH=/nix/store/...-gmp-6.1.2-dev/include
-DGUILE_SITE_DIR:PATH=share/guile/site
-DPYTHON_DEST:PATH=lib/python3.6/site-packages
-DCXXTEST_BIN_DIR:PATH=/nix/store/...-cxxtest-4.4/bin
-DCPLUS_INCLUDE_PATH:PATH=/nix/store/...-source
linas commented 4 years ago

OK, clearly my random approach to cmake is failing. Can you try this patch:

--- a/opencog/atoms/atom_types/CMakeLists.txt
+++ b/opencog/atoms/atom_types/CMakeLists.txt
@@ -23,6 +23,7 @@ SET_SOURCE_FILES_PROPERTIES(core_types.pyx PROPERTIES GENERATED TRUE)
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})

 ADD_LIBRARY (atom_types
+       atom_types.h
        atom_types_init.cc
        NameServer.cc
        )
Radivarig commented 4 years ago

Still the same

linas commented 4 years ago

I'm stuck then. I read 6 or 8 different stackexchange/blog/email threads on this issue, and (as you can verify) the cmakefile has implemented all of the suggestions that they all recommend.

Examining build/opencog/atoms/atom_types/Makefile, there should have been a line that says

NameServer.cc.o: atom_types.h

so that the complie of NameServer.cc doesn't start until after atom_types.h is generated. But I see no such dependency, and cmake doesn't allow me to manually specify it.

Alternately, build/opencog/atoms/atom_types/CMakeFiles/atom_types.dir/build.make should have listed this dependency... bizarrely, neither file makes any mention at all of atom_types.h...

Oh wait: it's here: build/opencog/atoms/atom_types/CMakeFiles/atom_types.dir/depend.make ... but that does not seem to trigger the build .... Hmmm.

Changing it to this:

--- a/opencog/atoms/atom_types/NameServer.cc
+++ b/opencog/atoms/atom_types/NameServer.cc
@@ -32,7 +32,8 @@
 #include <exception>

 #include <opencog/atoms/atom_types/types.h>
-#include <opencog/atoms/atom_types/atom_types.h>
+// #include <opencog/atoms/atom_types/atom_types.h>
+#include "atom_types.h"
 #include <opencog/atoms/value/Value.h>
 #include <opencog/util/exceptions.h>

produces an error .. which suggests that ... ???

linas commented 4 years ago

I also tried this:

--- a/opencog/atoms/atom_types/CMakeLists.txt
+++ b/opencog/atoms/atom_types/CMakeLists.txt
@@ -20,7 +20,7 @@ SET_SOURCE_FILES_PROPERTIES(atom_types.inheritance PROPERTIES GENERATED TRUE)
 SET_SOURCE_FILES_PROPERTIES(core_types.pyx PROPERTIES GENERATED TRUE)

 # The atom_types.h file is written to the build directory
-INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/opencog/atoms/atom_types)

 ADD_LIBRARY (atom_types
        atom_types_init.cc

together with

--- a/opencog/atoms/atom_types/NameServer.cc
+++ b/opencog/atoms/atom_types/NameServer.cc
@@ -32,7 +32,8 @@
 #include <exception>

 #include <opencog/atoms/atom_types/types.h>
-#include <opencog/atoms/atom_types/atom_types.h>
+// #include <opencog/atoms/atom_types/atom_types.h>
+#include "atom_types.h"
 #include <opencog/atoms/value/Value.h>
 #include <opencog/util/exceptions.h> 

but the resulting ./CMakeFiles/atom_types.dir/depend.make seems to be same as before.

Any chance that an an rm -r build might fix this? It seems that cmake doesn't always recreate the dependency files; maybe you have an old one sticking around?

When I make -j, I see this:

-- Atom type name: AttractionLink Attraction
-- Atom type name: ExecutionLink Execution
[  0%] Built target opencog_atom_types
Scanning dependencies of target atom_types
[  0%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/atom_types_init.cc.o
[  3%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/NameServer.cc.o
[  3%] Linking CXX shared library libatom_types.so
[  3%] Built target atom_types

which suggests that my cmake finished creating atom_types.h before starting in on NameServer.cc ... but your's says more-or-less the same thing.

Is there a chance that you have a broken atom_types.h installed somewhere in /usr/include ?

Radivarig commented 4 years ago

When I start the build with make -j, cancel it on errors and then start it again with make -j, the build succeeds. I found the atom_types.h in there after the first failed build. However, the output seems like the one from a non-parallel build.

make -j
[  0%] Built target SCM_CONFIG
Scanning dependencies of target executioncontext
[  0%] Built target opencog_atom_types
[  0%] Built target persist-pg
[  0%] Building CXX object opencog/cython/opencog/CMakeFiles/logger_cython.dir/logger.cpp.o
[  0%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/atom_types_init.cc.o
[  0%] Building CXX object opencog/atoms/atom_types/CMakeFiles/atom_types.dir/NameServer.cc.o
[  2%] Cythonizing atomspace.pyx
[  2%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_atoms_atom_types
[  2%] Building CXX object opencog/cython/executioncontext/CMakeFiles/executioncontext.dir/Context.cc.o
[  2%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_sheaf
[  2%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_matrix
[  2%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__home_radivarig_projects_opencog-dev_source_opencog_scm
[  2%] Built target py_atomspace_header
[  2%] Linking CXX shared library libexecutioncontext.so
[  2%] Built target executioncontext
[  2%] Linking CXX shared library logger.so
[  2%] Built target logger_cython
[  2%] Linking CXX shared library libatom_types.so
[  2%] Built target atom_types
...

atom_types.h in difference in folders before and after the first build:

λ diff -qr buildFailed/ buildRaw/
Only in buildFailed/CMakeFiles: Progress
Only in buildFailed/opencog/atoms/atom_types: atom_types.definitions

Only in buildFailed/opencog/atoms/atom_types: atom_types.h

Only in buildFailed/opencog/atoms/atom_types: atom_types.inheritance
Only in buildFailed/opencog/atoms/atom_types/CMakeFiles/atom_types.dir: CXX.includecache
Only in buildFailed/opencog/atoms/atom_types/CMakeFiles/atom_types.dir: depend.internal
Files buildFailed/opencog/atoms/atom_types/CMakeFiles/atom_types.dir/depend.make and buildRaw/opencog/atoms/atom_types/CMakeFiles/atom_types.dir/depend.make differ
...

Also there are no /usr/include/ or other shared folders as everything is stored in read-only /nix/store/ so every build I start is done in a sandbox with the same conditions, no leftovers from previous build. Debugging by hand is almost pure, it is done by my user instead of nix build restricted user, but I get the same output on the first build like in the pure build.

linas commented 4 years ago

I think that when the compilation of NameServer.cc starts, the atom_types.h file is still being written to, and thus is incomplete. If you ctrl-C it, then you only control-C the make, and not the generation of the file, so that, later, by the time you look at it, the atom_types.h file is finished, complete.

linas commented 4 years ago

Maybe this fixes it:

--- a/cmake/OpenCogAtomTypes.cmake
+++ b/cmake/OpenCogAtomTypes.cmake
@@ -35,6 +35,8 @@ IF (NOT PYTHON_FILE)
     MESSAGE(FATAL_ERROR "OPENCOG_ADD_ATOM_TYPES missing PYTHON_FILE")
 ENDIF (NOT PYTHON_FILE)

+FILE(LOCK foo.txt)
+
 SET(CNAMES_FILE ${CMAKE_BINARY_DIR}/atom_names.h)

 SET(CLASSSERVER_REFERENCE "opencog::nameserver().")
--- a/opencog/atoms/atom_types/CMakeLists.txt
+++ b/opencog/atoms/atom_types/CMakeLists.txt
@@ -22,6 +22,8 @@ SET_SOURCE_FILES_PROPERTIES(core_types.pyx PROPERTIES GENERATED TRUE)
 # The atom_types.h file is written to the build directory
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})

+FILE(LOCK foo.txt)
+
 ADD_LIBRARY (atom_types
        atom_types_init.cc
        NameServer.cc
linas commented 4 years ago

OK, so now I am fully and completely sure that for sure this time for real, without a doubt, that pull req opencog/atomspace#2450 will fix this. Finally.

Radivarig commented 4 years ago

A different output at least! There is no longer a bunch of output, instead it breaks on a single error:

...
[  6%] Built target COPY_TO_LOAD_PATH_IN_BUILD_DIR_FROM__build_source_opencog_scm
-- Atom type name: LambdaLink Lambda
-- Atom type name: PutLink Put
-- Atom type name: PatternLink Pattern
-- Atom type name: SatisfyingLink Satisfying
-- Atom type name: GetLink Get
-- Atom type name: QueryLink Query
-- Atom type name: BindLink Bind
-- Atom type name: DualLink Dual
-- Atom type name: EvaluationLink Evaluation
In file included from /build/source/opencog/atoms/value/Value.h:31:0,
                 from /build/source/opencog/atoms/value/FloatValue.h:27,
                 from /build/source/opencog/atoms/truthvalue/TruthValue.h:35,
                 from /build/source/opencog/atomspace/AtomSpace.h:31,
                 from /build/source/opencog/cython/executioncontext/Context.h:1,
                 from /build/source/opencog/cython/executioncontext/Context.cc:1:
/build/source/opencog/atoms/atom_types/NameServer.h:34:10: fatal error: opencog/atoms/atom_types/atom_types.h: No such file or directory
 #include <opencog/atoms/atom_types/atom_types.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
-- Atom type name: EquivalenceLink Equivalence
make[2]: *** [opencog/cython/executioncontext/CMakeFiles/executioncontext.dir/build.make:63: opencog/cython/executioncontext/CMakeFiles/executioncontext.dir/Context.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2532: opencog/cython/executioncontext/CMakeFiles/executioncontext.dir/all] Error 2

And I've checked /build/opencog/atoms/atom_types/atom_types.h does not exist after the error

linas commented 4 years ago

I give up. See https://stackoverflow.com/questions/59420384/cmake-how-do-i-declare-a-dependency-on-a-generated-header-file maybe someone else will figure it out.

In the meanwhile, as a work-around, try calling make twice.

linas commented 4 years ago

or not ... please try again with opencog/atomspace#2450 My latest theory is that a recent python change messed up dependencies (specifically, this one: opencog/atomspace#2420) and maybe that was lurking at the bottom of all the other failures.

Ugh. Now I'm completely sure that was the issue, and its now fixed. This took wayyyy too much effort. All I've got to show for it is that next time, if it ever happens again, the error messages will be a lot more obvious/direct.

Radivarig commented 4 years ago

Yes, that solves it! This was fun :smile:

linas commented 4 years ago

fun for who? :smile:

Radivarig commented 4 years ago

Yeah sorry, well I enjoy to observe your expertise in action. I think it's awesome, regardless of the obstacles part it ends with a solution, so thumbs up from me! Not so happy to see it took much time, I tried to tackle it myself but there are many mysteries for me here, so the best I can do is research one by one and make sure my reports are precise.

linas commented 4 years ago

I forgot to tag with a smiley-face when I wrote that.

Like all human activities, personal satisfaction during software devel has ups & downs. I like bug-hunting, it's rewarding the way mystery thrillers are. I dislike it, because it's like crossword-puzzles: vaguely enjoyable while you do it, but to what end? It's an activity that puts you "in the zone", in a flow state. But is there something more important to be done, instead?

Here, I'm kicking myself. Your bisect clearly pointed at the problem (the addition of a broken CMakefile) but I didn't see it because it looked like python, not CMake. So I ignored it, went on a wild-goose chase. So I'm angry at myself for having missed the important clue. I'm trying not to be angry at the person who created the broken CMakefile. I'm more than a little irritated that the cmake infrastructure cannot automate this sort of stuff. There's all this mumbo-jumbo philosophy about file-globbing in cmake, but this is a case where that philosophy clearly failed. So I'm left with this mix: a missed clue, an incorrect cmakefile, and cmake as a tool that allows such mistakes to happen. And so the adventure ends...