Sqlite building failure using rtems-source-builder

JunBeom Kim jbkim at e-coretech.kr
Fri Mar 29 06:57:43 UTC 2019


Dear Jonathan,

Thank you very much for this information.

I am using sqlite.c SQLITE_AMALGAMATION old version code.
I think that lastest version is almost same with old version.

I used below predefine option for building sqlite3.c
  -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_COMPLETE
  -DSQLITE_OMIT_WAL=1 -DSQLITE_ENABLE_COLUMN_METADATA=1

Because there is file locking problem due to fcntl(F_SETLK) unsupported feature, DB file access is error.
Therefore, I just modify this in below;

I inserted predefine option(#define USE_RTEMS)

static int unixFileLock(unixFile *pFile, struct flock *pLock){
  int rc;
  unixInodeInfo *pInode = pFile->pInode;
  assert( unixMutexHeld() );
  assert( pInode!=0 );
  if( ((pFile->ctrlFlags & UNIXFILE_EXCL)!=0 || pInode->bProcessLock)
   && ((pFile->ctrlFlags & UNIXFILE_RDONLY)==0)
  ){
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
      lock.l_type = F_WRLCK;
      rc = osFcntl(pFile->h, F_SETLK, &lock);
#ifndef USE_RTEMS
      if( rc<0 ) return rc;
#endif	  
      pInode->bProcessLock = 1;
      pInode->nLock++;
    }else{
      rc = 0;
    }
  }else{
    rc = osFcntl(pFile->h, F_SETLK, pLock);
  }
#ifndef USE_RTEMS
  return rc;
#else
  return 0;
#endif
}

Whenever fcntl(F_SETLK) is used, I fcntl always return 0(successful).

After I modify this, there is not problem using simple sqlite example code(attached: main.c).
But, there is side-effect(for example: memory leaking issue by locking patch code) in my customer side using RTEMS.

I have tried to build sqlite using rtems-source-builder as this reason.
I guess that there is additional predefine option for resolving this.

Best Regards,
JunBeom

-----Original Message-----
From: Jonathan Brandmeyer <jbrandmeyer at planetiq.com> 
Sent: Tuesday, March 26, 2019 11:25 PM
To: JunBeom Kim <jbkim at e-coretech.kr>
Cc: users at rtems.org
Subject: Re: Sqlite building failure using rtems-source-builder

My team hasn't gotten to the stage of actually using SQLite in the RTEMS environment yet, but it builds just fine.  We don't use rtems-source-builder to do it.  We are just using the latest stable amalgamation release, supplied by sqlite.org.  We build it with the same options that the configure script normally uses to build a .so on Linux, except that we also specify -DSQLITE_OMIT_LOAD_EXTENSION.  I've seen some documentation to the effect that rtems actually does support dlopen/dlsym, but we haven't tried it and we don't need it for our mission.

If I understand correctly, the only conflicts with RTEMS should be SQLIte's dependency on mmap.  RTEMS does not provide virtual memory at all, so mmap and kin are only stub functions that return an error.
The SQLite3 documentation does describe how to configure the write-ahead log (WAL) in such a way that it should not rely on mmap at runtime, though.

Hope that helps,
--
Jonathan Brandmeyer
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.c
URL: <http://lists.rtems.org/pipermail/users/attachments/20190329/435316f0/attachment-0002.c>


More information about the users mailing list