hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Compilation failure due to double slash vs single slash in path identifiers

Open davidsklar opened this issue 15 years ago • 3 comments

Different parts of hphp are generating different identifiers for a function, one puts double / in a pathname, one a single / -- so the conflict leads to an undefined symbol.

I run hphp with the following shell script:

#!/bin/bash                                                                        

export HPHP_HOME=/home/david/hphp/hiphop-php
export HPHP_LIB=$HPHP_HOME/bin
export CMAKE_PREFIX_PATH=/home/david/hphp
PEANUT_DIR=/home/david/peanut

find $PEANUT_DIR/*.php $PEANUT_DIR/lib -name \*.php > input-files.txt

$HPHP_HOME/src/hphp/hphp --config hpeanut.config --program hpeanut --input-list input-files.txt --log=3 --keep-tempdir=1

Which produces the following output:

running hphp...
creating temporary directory /tmp/hphp_LSPMVs ...
parsing inputs...
parsing inputs took 0'00" (7 ms) wall time
pre-optimizing...
pre-optimizing took 0'00" (1 ms) wall time
inferring types...
inferring types took 0'00" (0 ms) wall time
post-optimizing...
post-optimizing took 0'00" (0 ms) wall time
creating CPP files...
creating CPP files took 0'00" (68 ms) wall time
compiling and linking CPP files...
/tmp/hphp_LSPMVs/php/home/david/peanut/index.cpp: In function \xe2\x80\x98HPHP::Variant HPHP::pm_php$$home$david$peanut$index_php(bool, HPHP::LVariableTable*, HPHP::Globals*)\xe2\x80\x99:\n/tmp/hphp_LSPMVs/php/home/david/peanut/index.cpp:24: error: \xe2\x80\x98pm_php$home$david$peanut$lib$index_php\xe2\x80\x99 was not declared in this scope\nmake[2]: *** [CMakeFiles/hpeanut.dir/php/home/david/peanut/index.cpp.o] Error 1\nmake[1]: *** [CMakeFiles/hpeanut.dir/all] Error 2\nmake: *** [all] Error 2\n

The hpeanut.config file referenced by the shell script contains:

IncludeRoots {
 * {
   root = $_SERVER['DOCUMENT_ROOT']
   path = /home/david/peanut
   }
 * {
   root = APP_BASE
   path = /home/david/peanut
   }
}

The input-files.txt generated by the shell script contains:

/home/david/peanut/index.php                                                       
/home/david/peanut/lib/index.php

/home/david/peanut/index.php contains:

<?php
define('APP_BASE',dirname(__FILE__));
require_once APP_BASE . '/lib/index.php';

/home/david/peanut/lib/index.php contains:

I am lib/index.php

The generated index.cpp file contains:


#include <php//home/david/peanut/index.h>                                          
#include <php//home/david/peanut/index.fws.h>                                      

// Dependencies                                                                    
#include <php/home/david/peanut/lib/index.h>
#include <runtime/ext/ext.h>
namespace hphp_impl_starter {}

namespace HPHP {
///////////////////////////////////////////////////////////////////////////////    

/* preface starts */
extern CallInfo ci_;
/* preface finishes */
Variant pm_php$$home$david$peanut$index_php(bool incOnce /* = false */, LVariableTable* variables /* = NULL */, Globals *globals /* = get_globals() */) {
  PSEUDOMAIN_INJECTION(run_init::/home/david/peanut/index.php, pm_php$$home$david$peanut$index_php);
  LVariableTable *gVariables ATTRIBUTE_UNUSED = (LVariableTable *)g;
  {
    LINE(2,0);
    const String &tmp0((x_dirname(get_source_filename("/home/david/peanut/index.php"))));
    g->declareConstant(NAMSTR(s_ss6519bd01, "APP_BASE"), g->k_APP_BASE, tmp0);
  }
  LINE(3,(pm_php$home$david$peanut$lib$index_php(true, variables, g)));
  return true;
}
namespace hphp_impl_splitter {}

///////////////////////////////////////////////////////////////////////////////    
}

Note the double-slash in the pathname in the first two #include statements. The compilation failure is due to the mismatch between how the function is declared (" pm_php$$home$david$peanut$index_php") and how it's referred to inside the LINE() macro ("pm_php$home$david$peanut$lib$index_php").

davidsklar avatar Jun 27 '11 19:06 davidsklar

FWIW, lcastelli's commit https://github.com/lcastelli/hiphop-php/commit/4c1fda0256b71bb280683207483cf0bc60df156c does not fix this issue.

davidsklar avatar Jun 27 '11 19:06 davidsklar

And adding this to my config file allows compilation to succeed:

CodeGeneration { UserFilePrefix = php }

Not sure this is the best long-term solution, though.

davidsklar avatar Jun 27 '11 19:06 davidsklar

We're closing out all bugs older than 2 months. http://www.hiphop-php.com/wp/?p=575

If this is still an issue, please re-open it, and in order of goodness:

  1. Give detailed repro steps
  2. Write a test case in hphp/tests/quick (run it with hphp/tests/run) and send the pull request
  3. Fix it in a pull request

ptarjan avatar May 13 '13 22:05 ptarjan